feat: skip postinstall steps in case CLI is not installed globally #4317
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In case the CLI package is not installed globally, probably it is installed as a dependency of a project or as a dependency of other dependency.
In this case the postinstall actions have no meaning for the user, as probably CLI will be used as a library.
Skip all of the postinstall actions in such case. Remove the execution code of the old
post-install
command and move it topost-install-cli
command.Add unit tests. Remove a property from staticConfig - it has no meaning to be there, just place it in the postinstall command directly.
Handle case when CLI is installed globally with npm or yarn - in both cases the
npm_config_argv
will be populated with the original command. For example:npm i -g nativescript
- thenpm_config_argv
will be:["i", "-g", "nativescript"]
yarn global add nativescript
- thenpm_config_argv
will be:["global", "add", "nativescript"]
PR Checklist
What is the current behavior?
When executing
npm i nativescript
, you are prompted to enable autocompletion and all other post install tasks.What is the new behavior?
CLI will ask you to enable autocompletion (and other questions asked on post-install) only when
npm i -g nativescript
oryarn global add nativescript
is used.Implements issue #4323