diff options
author | Nathan Rajlich <nathan@tootallnate.net> | 2012-08-06 10:18:27 -0700 |
---|---|---|
committer | Nathan Rajlich <nathan@tootallnate.net> | 2012-08-06 10:18:27 -0700 |
commit | 7a9db6cfb139a6cb5941b2ae09ab5671e474e160 (patch) | |
tree | cea45bed07b8f86f5c165f065fed83fefaa3ddb6 /tools | |
parent | 6bdd4d0205a86ad40f78d3140144eebb83f703ca (diff) | |
download | nodejs-7a9db6cfb139a6cb5941b2ae09ab5671e474e160.tar.gz nodejs-7a9db6cfb139a6cb5941b2ae09ab5671e474e160.tar.bz2 nodejs-7a9db6cfb139a6cb5941b2ae09ab5671e474e160.zip |
install: add a "portable" mode to the shebang-rewriting logic
This "portable" mode rewrites the npm shebang to use the "node" executable
in the same directory relative to the "npm" script. This makes the "npm"
script "just work" even when "node" is not in the user's $PATH.
This mode is necessary for the precompiled binary packages that may potentially
be extracted to anywhere. The regular shebang-rewriting logic would normally
set the npm script's shebang to "/bin/node" which will not be present on anyone's
machine. In the end, we want the precompiled packages to be as user-friendly as
possible.
Diffstat (limited to 'tools')
-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 d11d281a8..1dd039a86 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 |