@@ -423,8 +423,8 @@ func (npmrc *NpmRC) installPackageContext(ctx context.Context, pkg npm.Package)
423423 return
424424}
425425
426- func (npmrc * NpmRC ) installDependencies (wd string , pkgJson * npm.PackageJSON , npmMode bool , mark * set.Set [string ]) {
427- _ = npmrc .installDependenciesContext (context .Background (), wd , pkgJson , npmMode , mark )
426+ func (npmrc * NpmRC ) installDependencies (wd string , pkgJson * npm.PackageJSON , npmMode bool , mark * set.Set [string ]) error {
427+ return npmrc .installDependenciesContext (context .Background (), wd , pkgJson , npmMode , mark )
428428}
429429
430430func (npmrc * NpmRC ) installDependenciesContext (ctx context.Context , wd string , pkgJson * npm.PackageJSON , npmMode bool , mark * set.Set [string ]) error {
@@ -454,8 +454,13 @@ func (npmrc *NpmRC) installDependenciesContext(ctx context.Context, wd string, p
454454 }
455455 errMu .Unlock ()
456456 }
457+ getFirstErr := func () error {
458+ errMu .Lock ()
459+ defer errMu .Unlock ()
460+ return firstErr
461+ }
457462 for name , version := range dependencies {
458- if ctx .Err () != nil || firstErr != nil {
463+ if ctx .Err () != nil || getFirstErr () != nil {
459464 break
460465 }
461466 wg .Add (1 )
@@ -502,7 +507,14 @@ func (npmrc *NpmRC) installDependenciesContext(ctx context.Context, wd string, p
502507 if strings .ContainsRune (name , '/' ) {
503508 ensureDir (filepath .Dir (linkDir ))
504509 }
505- os .Symlink (filepath .Join (npmrc .StoreDir (), pkg .String (), "node_modules" , pkg .Name ), linkDir )
510+ err = os .Symlink (filepath .Join (npmrc .StoreDir (), pkg .String (), "node_modules" , pkg .Name ), linkDir )
511+ if err != nil && ! os .IsExist (err ) {
512+ setErr (err )
513+ return
514+ }
515+ } else if err != nil {
516+ setErr (err )
517+ return
506518 }
507519 // install dependencies recursively
508520 if len (installed .Dependencies ) > 0 || (len (installed .PeerDependencies ) > 0 && npmMode ) {
0 commit comments