@@ -65,6 +65,11 @@ const (
6565 // EnvvarBuildDir names the environment variable we take the build dir location from
6666 EnvvarBuildDir = "LEEWAY_BUILD_DIR"
6767
68+ // EnvvarYarnMutex configures the mutex flag leeway will pass to yarn.
69+ // See https://yarnpkg.com/lang/en/docs/cli/#toc-concurrency-and-mutex for possible values.
70+ // Defaults to "network".
71+ EnvvarYarnMutex = "LEEWAY_YARN_MUTEX"
72+
6873 // dockerImageNamesFiles is the name of the file store in poushed Docker build artifacts
6974 // which contains the names of the Docker images we just pushed
7075 dockerImageNamesFiles = "imgnames.txt"
@@ -162,7 +167,7 @@ func Build(pkg *Package, localCache Cache, remoteCache RemoteCache) error {
162167 allpkg := append (requirements , pkg )
163168
164169 ctx , err := newBuildContext (localCache )
165- var errs [] string
170+ unresolvedArgs := make ( map [ string ][] string )
166171 for _ , dep := range allpkg {
167172 _ , exists := ctx .LocalCache .Location (dep )
168173 if exists {
@@ -171,14 +176,24 @@ func Build(pkg *Package, localCache Cache, remoteCache RemoteCache) error {
171176
172177 ua , err := FindUnresolvedArguments (dep )
173178 if err != nil {
174- errs = append ( errs , err . Error ())
179+ return err
175180 }
176- if len (ua ) != 0 {
177- errs = append (errs , fmt .Sprintf ("%s: cannot build with unresolved arguments: %s" , dep .FullName (), strings .Join (ua , ", " )))
181+ for _ , arg := range ua {
182+ pkgs , ok := unresolvedArgs [arg ]
183+ if ! ok {
184+ pkgs = []string {}
185+ }
186+ pkgs = append (pkgs , dep .FullName ())
187+ unresolvedArgs [arg ] = pkgs
178188 }
179189 }
180- if len (errs ) != 0 {
181- return xerrors .Errorf (strings .Join (errs , "\n " ))
190+ if len (unresolvedArgs ) != 0 {
191+ var msg string
192+ for arg , pkgs := range unresolvedArgs {
193+ cleanArg := strings .TrimSuffix (strings .TrimPrefix (arg , "${" ), "}" )
194+ msg += fmt .Sprintf ("cannot build with unresolved argument \" %s\" : use -D%s=value to set the argument\n \t %s appears in %s\n \n " , arg , cleanArg , arg , strings .Join (pkgs , ", " ))
195+ }
196+ return xerrors .Errorf (msg )
182197 }
183198
184199 err = remoteCache .Download (ctx .LocalCache , requirements )
@@ -431,7 +446,11 @@ func (p *Package) buildTypescript(buildctx *buildContext, wd, result string) (er
431446
432447 // The yarn cache cannot handly conccurency proplery and needs to be looked.
433448 // Make sure that all our yarn install calls lock the yarn cache.
434- yarnMutex := "file://" + filepath .Join (buildctx .BuildDir (), "yarn-mutex" )
449+ yarnMutex := os .Getenv (EnvvarYarnMutex )
450+ if yarnMutex == "" {
451+ log .Debug ("%s is not set, defaulting to \" network\" " , EnvvarYarnMutex )
452+ yarnMutex = "network"
453+ }
435454 yarnCache := filepath .Join (buildctx .BuildDir (), "yarn-cache" )
436455 commands = append (commands , []string {"yarn" , "install" , "--mutex" , yarnMutex , "--cache-folder" , yarnCache })
437456 if len (cfg .BuildCmd ) == 0 {
0 commit comments