Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

fixes #11552 #11553

Merged
merged 2 commits into from
Sep 11, 2015
Merged

fixes #11552 #11553

merged 2 commits into from
Sep 11, 2015

Conversation

zaggino
Copy link
Contributor

@zaggino zaggino commented Aug 6, 2015

for #11552

@nethip
Copy link
Contributor

nethip commented Aug 7, 2015

@zaggino: just a quick comment. I see that the documentation for the apis is missing for the new parameter. Could you add description for the newly added parameter at all the places where it is added?

@@ -207,7 +207,7 @@ function legacyPackageCheck(legacyDirectory) {
* @param {function} callback (err, result)
* @param {boolean} _doUpdate private argument to signal that an update should be performed
*/
function _cmdInstall(packagePath, destinationDirectory, options, callback, _doUpdate) {
function _cmdInstall(packagePath, destinationDirectory, options, callback, pCallback, _doUpdate) {
Copy link
Contributor

Choose a reason for hiding this comment

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

It is usually better to add new params at the end, unless there is a reason.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

there's a reason, progress callback was added right after callback argument, unfortunately, it also caused a collision with this "private" argument

@zaggino
Copy link
Contributor Author

zaggino commented Aug 7, 2015

params noted where they were missing

@@ -272,7 +273,7 @@ function _cmdInstall(packagePath, destinationDirectory, options, callback, _doUp
// If the extension is already there, we signal to the front end that it's already installed
// unless the front end has signaled an intent to update.
if (hasLegacyPackage || fs.existsSync(installDirectory) || fs.existsSync(systemInstallDirectory)) {
if (_doUpdate) {
if (_doUpdate === true) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this actually make a difference?

Copy link
Member

Choose a reason for hiding this comment

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

I'm assuming the intent was to prevent similar bugs in the future: if you accidentally pass an extra callback arg in this position, it's truthy but not === true.

That said, silently acting like the param was false doesn't necessarily mean we're preventing the mistake from causing a bug. Might be nice to have something like console.assert(_doUpdate === undefined || typeof _doUpdate === "boolean") at the top if we're truly worried about this problem happening again.

Or the other option would be to add a unit test that covers this, so that regardless of what breaks it we'd find out via a failing test :-)

@abose abose added this to the Release 1.5 milestone Sep 11, 2015
@abose
Copy link
Contributor

abose commented Sep 11, 2015

@zaggino Can we check this change in and add the unit tests as another PR or should this pr be updated?

@zaggino
Copy link
Contributor Author

zaggino commented Sep 11, 2015

sure, this is good to check-in... and sorry, but i don't have time to put together a proper test right now

abose added a commit that referenced this pull request Sep 11, 2015
@abose abose merged commit 96023c4 into master Sep 11, 2015
@abose
Copy link
Contributor

abose commented Sep 11, 2015

thanks 👍
Merging.

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

Successfully merging this pull request may close these issues.

5 participants