Per issue #46 the `ASDF_INSTALL_VERSION` variable is not available in global NPM installs. Instead the `npm_config_node_version` is provided by NPM during this situation.
This change offers a fallback in these cases. Since a version will be available this will significantly speed up the postinstall during global NPM installs.
Fixes#46
Proposed update to readme for Mac users who used `brew` to install the `asdf` package. `Brew` installed `asdf` in the folder `/usr/local/opt/`. I proposed this file change to help other Mac users who have decided to manage `asdf` installation with `brew`. Please close if you do not think this should be part of the readme for new users. Thank you.
`.asdf/bin/private/asdf-exec` sets `$ASDF_INSTALL_PATH` to the result of
`find_install_path` in `.asdf/lib/utils.sh` - which, if version is
`"system"` (which it is for the system nodejs, of course), returns an
empty string. This then, is passed to
`.asdf/plugins/nodejs/bin/exec-env`, and, if `$NPM_CONFIG_PREFIX` is
`""`, it is set to `$ASDF_INSTALL_PATH/.npm` - resulting in `"/.npm"`.
In my shell w/o `asdf` enabled which can run `npm`, `$NPM_CONFIG_PREFIX`
is blank; therefore a possible patch would be to only set
`$NPM_CONFIG_PREFIX` if it is blank _and_ `$ASDF_INSTALL_PATH` is _not_.
On some platforms, including Fedora and derivatives, and Arch and
derivatives, the binary `shasum` does not exist. Instead, sha256sum
should be used.
This patch checks for the existence of sha256sum, as well as shasum,
and uses whichever is present. If none are present, a helpful error
message is printed out.
Tested on Fedora 28
- Scenarios tested:
-------------------------------
| Sha256sum | shasum | Works? |
| Yes | No | Yes |
| No | Yes | Yes |
| Yes | Yes | Yes |
| No | No | Yes |
-------------------------------
A bug existed where, if no versions of `node` and `npm` are installed
already, running `asdf install node <version>` while having any packages
listed inside `.default-npm-packages` would fail to install those
default packages because the newly installed node version's `bin`
directory is not in the `PATH` yet.
Fixes#67
This works in tandom with a change in asdf core that will look for the
exec-path command and use it appropriately when found to conditionally
route the npm & npx commands to the correct executable path.