Bug 1767438 - Pick correct node instance by changing PATH. r=nalexander

Revert "Bug 1612191 - Pre: Use NPM's --scripts-prepend-node-path rather than setting PATH. r=Standard8"

This reverts git commit 787b41db545a08237c69486136ce4e13de9fd9e7.
It backs out of hg commit f05648a37233cb2cce775c57b2c393665b768c9b.

The config option that was being enabled has been removed in recent node versions.
See: https://github.com/npm/statusboard/issues/117

Differential Revision: https://phabricator.services.mozilla.com/D145417
This commit is contained in:
Simon Friedberger 2022-05-04 18:14:51 +00:00
Родитель 83568bcd62
Коммит 369066cd56
1 изменённых файлов: 11 добавлений и 5 удалений

Просмотреть файл

@ -141,15 +141,20 @@ def package_setup(
if platform.system() != "Windows":
cmd.insert(0, node_path)
cmd.extend(extra_parameters)
# Ensure that bare `node` and `npm` in scripts, including post-install scripts, finds the
# binary we're invoking with. Without this, it's easy for compiled extensions to get
# mismatched versions of the Node.js extension API.
extra_parameters.append("--scripts-prepend-node-path")
cmd.extend(extra_parameters)
path = os.environ.get("PATH", "").split(os.pathsep)
node_dir = os.path.dirname(node_path)
if node_dir not in path:
path = [node_dir] + path
print('Installing %s for mach using "%s"...' % (package_name, " ".join(cmd)))
result = call_process(package_name, cmd)
result = call_process(
package_name, cmd, append_env={"PATH": os.pathsep.join(path)}
)
if not result:
return 1
@ -166,8 +171,9 @@ def package_setup(
os.chdir(orig_cwd)
def call_process(name, cmd, cwd=None):
def call_process(name, cmd, cwd=None, append_env={}):
env = dict(os.environ)
env.update(append_env)
try:
with open(os.devnull, "w") as fnull: