@@ -82,12 +82,14 @@ class EnvironmentTestRunner {
8282 * Copy a directory from src to dest, excluding files that match the excludePatterns
8383 * @param src - The source directory
8484 * @param dest - The destination directory
85- * @param excludePatterns - An array of file names to exclude from the copy
85+ * @param excludePatterns - An array of file names to exclude from the copy (only at the top level)
86+ * @param isTopLevel - Whether this is the top level call (used to only apply excludePatterns at root)
8687 */
8788 private async copyDirectory (
8889 src : string ,
8990 dest : string ,
90- excludePatterns : string [ ] = [ ]
91+ excludePatterns : string [ ] = [ ] ,
92+ isTopLevel : boolean = true
9193 ) : Promise < void > {
9294 await fs . mkdir ( dest , { recursive : true } ) ;
9395
@@ -98,13 +100,17 @@ class EnvironmentTestRunner {
98100 const srcPath = path . join ( src , entry . name ) ;
99101 const destPath = path . join ( dest , entry . name ) ;
100102
101- // Skip excluded patterns
102- if ( excludePatterns . some ( ( pattern ) => entry . name === pattern ) ) {
103+ // Skip excluded patterns only at the top level
104+ // This allows dist/node_modules (bundled dependencies) to be copied
105+ if (
106+ isTopLevel &&
107+ excludePatterns . some ( ( pattern ) => entry . name === pattern )
108+ ) {
103109 return ;
104110 }
105111
106112 if ( entry . isDirectory ( ) ) {
107- await this . copyDirectory ( srcPath , destPath , excludePatterns ) ;
113+ await this . copyDirectory ( srcPath , destPath , excludePatterns , false ) ;
108114 } else {
109115 await fs . copyFile ( srcPath , destPath ) ;
110116 }
@@ -227,12 +233,10 @@ class EnvironmentTestRunner {
227233 return ;
228234 }
229235
230- let destDirName : string ;
231- if ( pkg . name === "langchain" ) {
232- destDirName = "langchain" ;
233- } else {
234- destDirName = pkg . name . replace ( "@langchain/" , "langchain-" ) ;
235- }
236+ const destDirName : string =
237+ pkg . name === "langchain"
238+ ? "langchain"
239+ : pkg . name . replace ( "@langchain/" , "langchain-" ) ;
236240 const destDir = path . join ( libsDir , destDirName ) ;
237241 await fs . mkdir ( destDir , { recursive : true } ) ;
238242
0 commit comments