Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hook to prevent auto-update of CLI during `ng update` #16122

Open
dgp1130 opened this issue Nov 8, 2019 · 4 comments

Comments

@dgp1130
Copy link
Collaborator

@dgp1130 dgp1130 commented Nov 8, 2019

馃殌 Feature request

Command (mark with an x)

- [ ] new
- [ ] build
- [ ] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [X] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Description

When running ng update, it automatically updates to the most recently released version. When doing local development, this is undesirable because devs want to use their locally built version.

Describe the solution you'd like

Either a --skip-self-update flag or an environment variable to avoid this behavior.

Describe alternatives you've considered

Only workaround is to manually change this line to an if (false) { /* ... */ } before a local build.

@dgp1130 dgp1130 self-assigned this Nov 8, 2019
@dgp1130 dgp1130 added this to the Backlog milestone Nov 8, 2019
@ngbot ngbot bot removed this from the Backlog milestone Nov 8, 2019
@alan-agius4

This comment has been minimized.

Copy link
Collaborator

@alan-agius4 alan-agius4 commented Nov 8, 2019

You can use the following env variable NG_DISABLE_VERSION_CHECK. Just be sure that you ran your local ng with either npx or yarn.

Example yarn ng update ....

@alan-agius4

This comment has been minimized.

Copy link
Collaborator

@alan-agius4 alan-agius4 commented Nov 8, 2019

Oh nevermind, there is no check for that in that method.

@dgp1130

This comment has been minimized.

Copy link
Collaborator Author

@dgp1130 dgp1130 commented Nov 8, 2019

Oh interesting, what does NG_DISABLE_VERSION_CHECK do if not preventing self-updating? Would it make sense to use the same environment variable to do so?

@alan-agius4

This comment has been minimized.

Copy link
Collaborator

@alan-agius4 alan-agius4 commented Nov 8, 2019

When that env variable is set to true or 1. The CLI will bypass parts of the bootstrapping logic and will force the usage of the currently invoked process. Typically the CLI will always use the local version. But in some cases such as ng update self update we want to use the currently spawned process.

const disableVersionCheckEnv = process.env['NG_DISABLE_VERSION_CHECK'];

I think we can use this env variable for this use case too. As also, if we use this, we will be reducing an HTTP call. Since the cli will set this variable when using the self update version, but currently we don鈥檛 check it during ng update and thus when running in self update mode the spawned process will try to redundantly fetch the latest manifest of the cli again.

So with 1 stone with hit 2 birds!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can鈥檛 perform that action at this time.