File tree 1 file changed +18
-5
lines changed
1 file changed +18
-5
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,16 @@ import { watchFiles } from './watchFiles'
9
9
const SERVERLESS_FOLDER = '.serverless'
10
10
const BUILD_FOLDER = '.build'
11
11
12
+ // handles broken symlinks
13
+ const symlinkExistsSync = ( path : string ) => {
14
+ try {
15
+ fs . lstatSync ( path ) ;
16
+ return true ;
17
+ } catch ( e ) {
18
+ return false ;
19
+ }
20
+ }
21
+
12
22
export class TypeScriptPlugin {
13
23
private originalServicePath : string
14
24
private isWatching : boolean
@@ -191,14 +201,17 @@ export class TypeScriptPlugin {
191
201
192
202
// copy development dependencies during packaging
193
203
if ( isPackaging ) {
194
- if ( fs . existsSync ( outModulesPath ) ) {
204
+ // symlinkExistsSync handles the broken symlink case
205
+ if ( fs . existsSync ( outModulesPath ) || symlinkExistsSync ( outModulesPath ) ) {
195
206
fs . unlinkSync ( outModulesPath )
196
207
}
197
208
198
- fs . copySync (
199
- path . resolve ( 'node_modules' ) ,
200
- path . resolve ( path . join ( BUILD_FOLDER , 'node_modules' ) )
201
- )
209
+ if ( fs . existsSync ( path . resolve ( 'node_modules' ) ) ) {
210
+ fs . copySync (
211
+ path . resolve ( 'node_modules' ) ,
212
+ outModulesPath
213
+ )
214
+ }
202
215
} else {
203
216
if ( ! fs . existsSync ( outModulesPath ) ) {
204
217
await this . linkOrCopy ( path . resolve ( 'node_modules' ) , outModulesPath , 'junction' )
You can’t perform that action at this time.
0 commit comments