@@ -55,10 +55,17 @@ def _yarn_modules_impl(ctx):
5555 execute (ctx , ["cp" , parse_yarn_lock_js , "internal/parse_yarn_lock.js" ])
5656 execute (ctx , ["cp" , yarn_js , "yarn.js" ])
5757
58+ install_path = [node .dirname ]
59+ for tool in ctx .attr .install_tools :
60+ tool_path = ctx .which (tool )
61+ if not tool_path :
62+ fail ("Required install tool '%s' is not in the PATH" % tool , "install_tools" )
63+ install_path .append (tool_path .dirname )
64+ install_path .append ("$PATH" )
65+
5866 # Build node_modules via 'yarn install'
5967 execute (ctx , [node , yarn_js , "install" ], quiet = True , environment = {
60- # postinstall scripts may need to find the node binary
61- "PATH" : "%s:$PATH" % ctx .path (node ).dirname ,
68+ "PATH" : ":" .join (install_path ),
6269 })
6370
6471 # Run the script and save the stdout to our BUILD file(s)
@@ -93,6 +100,9 @@ yarn_modules = repository_rule(
93100 default = Label ("@yarn//:bin/yarn.js" ),
94101 single_file = True ,
95102 ),
103+ # If specififed, augment the PATH environment variable with these
104+ # tools during 'yarn install'.
105+ "install_tools" : attr .string_list (),
96106 "package_json" : attr .label (
97107 mandatory = False ,
98108 allow_files = FileType (["package.json" ]),
0 commit comments