relocate.sh 673 B

1234567891011121314151617181920212223242526
  1. #!/usr/bin/env bash
  2. # Change the cli shebang to point at the specified node
  3. # Useful for when the program is moved around after install.
  4. # Also used by the default 'make install' in node to point
  5. # npm at the newly installed node, rather than the first one
  6. # in the PATH, which would be the default otherwise.
  7. # bash /path/to/npm/scripts/relocate.sh $nodepath
  8. # If $nodepath is blank, then it'll use /usr/bin/env
  9. dir="$(dirname "$(dirname "$0")")"
  10. cli="$dir"/bin/npm-cli.js
  11. tmp="$cli".tmp
  12. node="$1"
  13. if [ "x$node" = "x" ]; then
  14. node="/usr/bin/env node"
  15. fi
  16. node="#!$node"
  17. sed -e 1d "$cli" > "$tmp"
  18. echo "$node" > "$cli"
  19. cat "$tmp" >> "$cli"
  20. rm "$tmp"
  21. chmod ogu+x $cli