Skip to content

Commit

Permalink
fix: unset YARN_IGNORE_PATH before calling yarn in @nodejs targets
Browse files Browse the repository at this point in the history
Same as #1588 but for the @nodejs//:yarn && @nodejs//:yarn_node_repositories targets.

Unset YARN_IGNORE_PATH before calling yarn incase it is set so that
.yarnrc yarn-path is followed if set. This is for the case when calling
bazel from yarn with `yarn bazel …` and yarn follows yarn-path in
.yarnrc it will set YARN_IGNORE_PATH=1 which will prevent the bazel
call into yarn from also following the yarn-path as desired.
  • Loading branch information
gregmagolan committed Feb 1, 2020
1 parent 39bb821 commit aee3003
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 11 additions & 2 deletions internal/node/node_repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -529,8 +529,13 @@ if %errorlevel% neq 0 exit /b %errorlevel%
script = repository_ctx.path(npm_script),
))

# The entry points for yarn for osx/linux and windows
# Runs yarn using appropriate node entry point
# The entry points for yarn for osx/linux and windows.
# Runs yarn using appropriate node entry point.
# Unset YARN_IGNORE_PATH before calling yarn incase it is set so that
# .yarnrc yarn-path is followed if set. This is for the case when calling
# bazel from yarn with `yarn bazel ...` and yarn follows yarn-path in
# .yarnrc it will set YARN_IGNORE_PATH=1 which will prevent the bazel
# call into yarn from also following the yarn-path as desired.
if not is_windows:
# Yarn entry point
repository_ctx.file(
Expand All @@ -539,6 +544,7 @@ if %errorlevel% neq 0 exit /b %errorlevel%
# Generated by node_repositories.bzl
# Immediately exit if any command fails.
set -e
unset YARN_IGNORE_PATH
{get_script_dir}
"$SCRIPT_DIR/{node}" "$SCRIPT_DIR/{script}" "$@"
""".format(
Expand All @@ -558,6 +564,7 @@ set -e
""" + GET_SCRIPT_DIR + "".join([
"""
echo Running yarn "$@" in {root}
unset YARN_IGNORE_PATH
(cd "{root}"; "$SCRIPT_DIR/{node}" "$SCRIPT_DIR/{script}" "$@")
""".format(
root = repository_ctx.path(package_json).dirname,
Expand All @@ -572,6 +579,7 @@ echo Running yarn "$@" in {root}
"bin/yarn.cmd",
content = """@echo off
SET SCRIPT_DIR=%~dp0
SET "YARN_IGNORE_PATH="
"%SCRIPT_DIR%\\{node}" "%SCRIPT_DIR%\\{script}" %*
""".format(
node = paths.relativize(node_entry, "bin"),
Expand All @@ -586,6 +594,7 @@ SET SCRIPT_DIR=%~dp0
""" + "".join([
"""
echo Running yarn %* in {root}
SET "YARN_IGNORE_PATH="
cd "{root}"
CALL "%SCRIPT_DIR%\\{node}" "%SCRIPT_DIR%\\{script}" %*
if %errorlevel% neq 0 exit /b %errorlevel%
Expand Down
2 changes: 1 addition & 1 deletion internal/npm_install/npm_install.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ unset YARN_IGNORE_PATH
repository_ctx.file(
"_yarn.cmd",
content = """@echo off
set "YARN_IGNORE_PATH="
set "YARN_IGNORE_PATH="
cd "{root}" && "{yarn}" {yarn_args}
""".format(
root = root,
Expand Down

0 comments on commit aee3003

Please sign in to comment.