@@ -122,6 +122,10 @@ See the section on stamping in the [README](stamping)
122
122
cfg = "host" ,
123
123
executable = True ,
124
124
),
125
+ "_run_npm_bat_template" : attr .label (
126
+ default = Label ("@nodejs//:run_npm.bat.template" ),
127
+ allow_single_file = True ,
128
+ ),
125
129
"_run_npm_template" : attr .label (
126
130
default = Label ("@nodejs//:run_npm.sh.template" ),
127
131
allow_single_file = True ,
@@ -130,8 +134,10 @@ See the section on stamping in the [README](stamping)
130
134
131
135
# Used in angular/angular /packages/bazel/src/ng_package/ng_package.bzl
132
136
PKG_NPM_OUTPUTS = {
133
- "pack" : "%{name}.pack" ,
134
- "publish" : "%{name}.publish" ,
137
+ "pack_bat" : "%{name}.pack.bat" ,
138
+ "pack_sh" : "%{name}.pack.sh" ,
139
+ "publish_bat" : "%{name}.publish.bat" ,
140
+ "publish_sh" : "%{name}.publish.sh" ,
135
141
}
136
142
137
143
# Takes a depset of files and returns a corresponding list of file paths without any files
@@ -240,19 +246,23 @@ def create_package(ctx, deps_files, nested_packages):
240
246
241
247
def _create_npm_scripts (ctx , package_dir ):
242
248
args = ctx .actions .args ()
249
+
243
250
args .add_all ([
244
251
package_dir .path ,
245
- ctx .outputs .pack .path ,
246
- ctx .outputs .publish .path ,
252
+ ctx .outputs .pack_sh .path ,
253
+ ctx .outputs .publish_sh .path ,
247
254
ctx .file ._run_npm_template .path ,
255
+ ctx .outputs .pack_bat .path ,
256
+ ctx .outputs .publish_bat .path ,
257
+ ctx .file ._run_npm_bat_template .path ,
248
258
])
249
259
250
260
ctx .actions .run (
251
261
progress_message = "Generating npm pack & publish scripts" ,
252
262
mnemonic = "GenerateNpmScripts" ,
253
263
executable = ctx .executable ._npm_script_generator ,
254
- inputs = [ctx .file ._run_npm_template , package_dir ],
255
- outputs = [ctx .outputs .pack , ctx .outputs .publish ],
264
+ inputs = [ctx .file ._run_npm_template , ctx . file . _run_npm_bat_template , package_dir ],
265
+ outputs = [ctx .outputs .pack_sh , ctx .outputs .publish_sh , ctx . outputs . pack_bat , ctx . outputs . publish_bat ],
256
266
arguments = [args ],
257
267
# Must be run local (no sandbox) so that the pwd is the actual execroot
258
268
# in the script which is used to generate the path in the pack & publish
@@ -307,3 +317,23 @@ pkg_npm = rule(
307
317
doc = _DOC ,
308
318
outputs = PKG_NPM_OUTPUTS ,
309
319
)
320
+
321
+ def pkg_npm_macro (name , ** kwargs ):
322
+ pkg_npm (
323
+ name = name ,
324
+ ** kwargs
325
+ )
326
+ native .alias (
327
+ name = name + ".pack" ,
328
+ actual = select ({
329
+ "@bazel_tools//src/conditions:host_windows" : name + ".pack.bat" ,
330
+ "//conditions:default" : name + ".pack.sh" ,
331
+ }),
332
+ )
333
+ native .alias (
334
+ name = name + ".publish" ,
335
+ actual = select ({
336
+ "@bazel_tools//src/conditions:host_windows" : name + ".publish.bat" ,
337
+ "//conditions:default" : name + ".publish.sh" ,
338
+ }),
339
+ )
0 commit comments