nodenv-package-json-engine
nodenv-package-json-engine copied to clipboard
Add package-json subcommand
Significant refactor to support the traditional subcommand/bin/libexec structure of nodenv plugins.
- Removes
plugin_rootfrom bin, so we aren't polluting user's PATH with more stuff. - adds nodenv-package-json which provides
nodenv package-jsonsubcommand. This subcommand presently is a "reader" for package.json just asnodenv localprints the version specified from local.node-versionfile. Intend to have this command also be a "writer" in the future. - Splits the finding and reading of package.json into two separate sub utilities (nodenv-package-json-file and nodenv-package-json-read) which are corollaries to
nodenv-version-fileandnodenv-version-file-read. The benefit is that the origin hook can now print the path to the actual package.json that is affecting the node version, along with the version_spec from said file. It invokes these utilities without needing to source anything.
Also addresses some latent bugs:
- was finding package.json by
PWDbut should have been usingNODENV_DIRhttps://github.com/nodenv/nodenv-package-json-engine/blob/dbfd936a77c9f4b41a7cf31c571039638658ec01/libexec/nodenv-package-json-engine#L72 https://github.com/nodenv/nodenv/blob/4e096a821ad1e3c55634586c4798da472be5520c/libexec/nodenv-version-file#L25-L27
todo:
- [ ] resolve all scenarios of PWD vs NODENV_DIR
- [ ] ensure error is printed when no matching version found
- [ ] update shellcheck to leverage extension-based linting