@@ -4,9 +4,6 @@ load("//nodejs/private:os_name.bzl", "assert_node_exists_for_host", "node_exists
4
4
load ("//nodejs/private:node_versions.bzl" , "NODE_VERSIONS" )
5
5
load ("//nodejs/private:nodejs_repo_host_os_alias.bzl" , "nodejs_repo_host_os_alias" )
6
6
load ("//nodejs/private:toolchains_repo.bzl" , "PLATFORMS" , "toolchains_repo" )
7
- load ("@bazel_skylib//lib:paths.bzl" , "paths" )
8
- load ("@bazel_tools//tools/build_defs/repo:http.bzl" , "http_archive" )
9
- load ("@bazel_tools//tools/build_defs/repo:utils.bzl" , "maybe" )
10
7
11
8
# Default base name for node toolchain repositories
12
9
# created by the module extension
@@ -236,8 +233,9 @@ def _prepare_node(repository_ctx):
236
233
node_entry = "bin/node%s" % entry_ext
237
234
npm_entry = "bin/npm%s" % entry_ext
238
235
239
- node_bin_relative = paths .relativize (node_bin , "bin" )
240
- npm_script_relative = paths .relativize (npm_script , "bin" )
236
+ node_bin_relative = _strip_bin (node_bin )
237
+ npm_script_relative = _strip_bin (npm_script )
238
+ node_entry_relative = _strip_bin (node_entry )
241
239
242
240
# The entry points for node for osx/linux and windows
243
241
if not is_windows :
@@ -279,7 +277,7 @@ set -e
279
277
"$SCRIPT_DIR/{node}" "$SCRIPT_DIR/{script}" --scripts-prepend-node-path=false "$@"
280
278
""" .format (
281
279
get_script_dir = GET_SCRIPT_DIR ,
282
- node = paths . relativize ( node_entry , "bin" ) ,
280
+ node = node_entry_relative ,
283
281
script = npm_script_relative ,
284
282
),
285
283
executable = True ,
@@ -292,7 +290,7 @@ set -e
292
290
SET SCRIPT_DIR=%~dp0
293
291
"%SCRIPT_DIR%\\ {node}" "%SCRIPT_DIR%\\ {script}" --scripts-prepend-node-path=false %*
294
292
""" .format (
295
- node = paths . relativize ( node_entry , "bin" ) ,
293
+ node = node_entry_relative ,
296
294
script = npm_script_relative ,
297
295
),
298
296
executable = True ,
@@ -361,6 +359,12 @@ node_toolchain(
361
359
"""
362
360
repository_ctx .file ("BUILD.bazel" , content = build_content )
363
361
362
+ def _strip_bin (path ):
363
+ if not path .startswith ("bin/" ):
364
+ fail ("Expected path to start with 'bin/' but was %s" % path )
365
+
366
+ return path [len ("bin/" ):]
367
+
364
368
def _verify_version_is_valid (version ):
365
369
major , minor , patch = (version .split ("." ) + [None , None , None ])[:3 ]
366
370
if not major .isdigit () or not minor .isdigit () or not patch .isdigit ():
@@ -424,12 +428,5 @@ def nodejs_register_toolchains(name, register = True, **kwargs):
424
428
)
425
429
426
430
def rules_nodejs_dependencies ():
427
- maybe (
428
- http_archive ,
429
- name = "bazel_skylib" ,
430
- sha256 = "c6966ec828da198c5d9adbaa94c05e3a1c7f21bd012a0b29ba8ddbccb2c93b0d" ,
431
- urls = [
432
- "https://github.com/bazelbuild/bazel-skylib/releases/download/1.1.1/bazel-skylib-1.1.1.tar.gz" ,
433
- "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.1.1/bazel-skylib-1.1.1.tar.gz" ,
434
- ],
435
- )
431
+ # This is a no-op, but we keep it around for backwards compatibility.
432
+ return True
0 commit comments