File tree Expand file tree Collapse file tree 1 file changed +4
-16
lines changed
packages/amplify-cli/src/extensions/amplify-helpers Expand file tree Collapse file tree 1 file changed +4
-16
lines changed Original file line number Diff line number Diff line change @@ -77,13 +77,13 @@ const moveBackendResourcesToCurrentCloudBackend = (resources: $TSObject[]): void
77
77
}
78
78
79
79
fs . ensureDirSync ( targetDir ) ;
80
+ const isLambdaOrCustom =
81
+ resource ?. service === ServiceName . LambdaFunction || ( resource ?. service && resource ?. service . includes ( 'custom' ) ) ;
80
82
81
83
// in the case that the resource is being deleted, the sourceDir won't exist
82
84
if ( fs . pathExistsSync ( sourceDir ) ) {
83
- fs . copySync ( sourceDir , targetDir ) ;
84
- if ( resource ?. service === ServiceName . LambdaFunction || ( resource ?. service && resource ?. service . includes ( 'custom' ) ) ) {
85
- removeNodeModulesDir ( targetDir ) ;
86
- }
85
+ const nodeModulesFilterFn = ( src : string ) : boolean => path . basename ( src ) !== 'node_modules' ;
86
+ fs . copySync ( sourceDir , targetDir , { ...( isLambdaOrCustom ? { filter : nodeModulesFilterFn } : { } ) } ) ;
87
87
}
88
88
}
89
89
@@ -109,18 +109,6 @@ const moveBackendResourcesToCurrentCloudBackend = (resources: $TSObject[]): void
109
109
}
110
110
} ;
111
111
112
- const removeNodeModulesDir = ( currentCloudBackendDir : string ) : void => {
113
- const nodeModulesDirs = glob . sync ( '**/node_modules' , {
114
- cwd : currentCloudBackendDir ,
115
- absolute : true ,
116
- } ) ;
117
- for ( const nodeModulesPath of nodeModulesDirs ) {
118
- if ( fs . existsSync ( nodeModulesPath ) ) {
119
- fs . removeSync ( nodeModulesPath ) ;
120
- }
121
- }
122
- } ;
123
-
124
112
/**
125
113
* Update amplify-meta.json and backend-config.json
126
114
*/
You can’t perform that action at this time.
0 commit comments