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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to exclude -g argument from default update message #105

Merged
merged 2 commits into from Feb 18, 2017

Conversation

colingourlay
Copy link
Contributor

In cases where your CLI package also serves a secondary purpose as a dependency of a project (e.g. the new crop of single-dependency toolkits such as nwb), the default update message shouldn't be recommending a global npm install.

With this new option (isGlobal), the default behaviour stays the same, but it is now configurable. Of course, this has always been possible when using the message argument, but it's a shame for authors to lose out on the pretty boxen output when they just want to change a flag.

I've updated the tests to ensure this output is correct, but they could use a little refactoring now that more than one test uses a similar UpdateNotifier sub-class.

index.js Outdated
@@ -109,8 +109,10 @@ class UpdateNotifier {

opts = opts || {};

opts.isGlobal = typeof opts.isGlobal === 'boolean' ? opts.global : true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would prefer using Object.assign here. You could then drop line 110 too.

opts = Object.assign({global: true}, opts);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call!

test.js Outdated
' ╰────────────────────────────────────────────────╯',
'',
''
].join('\n'));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to test the whole output. Having many of these will make it hard to change for example the box style later. Instead just do a indexOf check for Run npm i update-notifier-tester to update, after running it through stripAnsi of course.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. Change coming!

test.js Outdated
latest: '1.0.0'
};
}
util.inherits(Control, updateNotifier.UpdateNotifier);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is now duplicated. Can you make it out of these test function and to the top of the function.

Bonus points for making it a ES2015 class instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One step at a time! I'll make the refactor and perhaps do the class conversion as a separate PR. I don't wanna mix up to many changes at once!

readme.md Outdated
Type: `boolean`<br>
Default: `true`

Include the `-g` argument in the default message's `npm i` recommendation. This is ignored if you supply your own `message`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe shortly explain when it can be useful to set this to false? Like you did in the PR description.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't want to make the description too long (as the rest were quite short), but if you feel like it's a good explanation, I'll work it in there. Thanks so much for all of this feedback!

@sindresorhus sindresorhus changed the title Added option to exclude -g argument from default update message. Add option to exclude -g argument from default update message Feb 17, 2017
@colingourlay
Copy link
Contributor Author

@sindresorhus that's your recommendations rolled in 👍

Copy link
Member

@SBoudrias SBoudrias left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes LGTM. I'll let Sindre merge if he's also satisfied.

@sindresorhus sindresorhus merged commit 607d3c9 into yeoman:master Feb 18, 2017
@sindresorhus
Copy link
Member

Looks very good. Thank you @colingourlay :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants