File tree Expand file tree Collapse file tree 1 file changed +18
-5
lines changed Expand file tree Collapse file tree 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'
99const SERVERLESS_FOLDER = '.serverless'
1010const BUILD_FOLDER = '.build'
1111
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+
1222export class TypeScriptPlugin {
1323 private originalServicePath : string
1424 private isWatching : boolean
@@ -191,14 +201,17 @@ export class TypeScriptPlugin {
191201
192202 // copy development dependencies during packaging
193203 if ( isPackaging ) {
194- if ( fs . existsSync ( outModulesPath ) ) {
204+ // symlinkExistsSync handles the broken symlink case
205+ if ( fs . existsSync ( outModulesPath ) || symlinkExistsSync ( outModulesPath ) ) {
195206 fs . unlinkSync ( outModulesPath )
196207 }
197208
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+ }
202215 } else {
203216 if ( ! fs . existsSync ( outModulesPath ) ) {
204217 await this . linkOrCopy ( path . resolve ( 'node_modules' ) , outModulesPath , 'junction' )
You can’t perform that action at this time.
0 commit comments