nodenv-package-json-engine icon indicating copy to clipboard operation
nodenv-package-json-engine copied to clipboard

Add package-json subcommand

Open jasonkarns opened this issue 6 years ago • 0 comments

Significant refactor to support the traditional subcommand/bin/libexec structure of nodenv plugins.

  • Removes plugin_root from bin, so we aren't polluting user's PATH with more stuff.
  • adds nodenv-package-json which provides nodenv package-json subcommand. This subcommand presently is a "reader" for package.json just as nodenv local prints the version specified from local .node-version file. 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-file and nodenv-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 PWD but should have been using NODENV_DIR https://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

jasonkarns avatar Jan 21 '19 16:01 jasonkarns