Skip to content

Instantly share code, notes, and snippets.

@jameswomack
Created October 20, 2017 04:35
Show Gist options
  • Select an option

  • Save jameswomack/87f03b0d30ccb336bd6c7bd230e65e3f to your computer and use it in GitHub Desktop.

Select an option

Save jameswomack/87f03b0d30ccb336bd6c7bd230e65e3f to your computer and use it in GitHub Desktop.
Check if NPM bins have been made available via PATH using Node.js on *nix
// CP.execSync('zsh -xl') <- example of getting all environment variable sets in the current ZSH load. Seems to not work for the subshells it's based on
// Determine if $SHELL (convention used by Bash & ZSH) is a path to ZSH & add a $PATH with the CWD NPM bin path prepended to the current user's zshrc file
!!~CP.execSync('echo $SHELL').toString().match(/(?!(^\/bin\/))([a-z]+)(?=(\n$))/g) || CP.execSync('echo \'export PATH=./node_modules/.bin:$PATH\' >> ~/.zshrc')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment