diff options
-rwxr-xr-x | tools/install.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/tools/install.py b/tools/install.py index d11d281a86..1dd039a865 100755 --- a/tools/install.py +++ b/tools/install.py @@ -154,7 +154,15 @@ def npm_files(action): action([link_path], 'bin/npm') elif action == install: try_symlink('../lib/node_modules/npm/bin/npm-cli.js', link_path) - shebang = os.path.join(node_prefix, 'bin/node') + if os.environ['PORTABLE']: + # This crazy hack is necessary to make the shebang execute the copy + # of node relative to the same directory as the npm script. The precompiled + # binary tarballs use a prefix of "/" which gets translated to "/bin/node" + # in the regular shebang modifying logic, which is incorrect since the + # precompiled bundle should be able to be extracted anywhere and "just work" + shebang = '/bin/sh\n// 2>/dev/null; exec "`dirname "$0"`/node" "$0" "$@"' + else: + shebang = os.path.join(node_prefix, 'bin/node') update_shebang(link_path, shebang) else: assert(0) # unhandled action type |