-
Notifications
You must be signed in to change notification settings - Fork 7.6k
fixes #11552 #11553
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) { | ||
if (!options || !options.disabledDirectory || !options.apiVersion || !options.systemExtensionDirectory) { | ||
callback(new Error(Errors.MISSING_REQUIRED_OPTIONS), null); | ||
return; | ||
|
@@ -272,7 +272,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) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this actually make a difference? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 That said, silently acting like the param was 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 :-) |
||
if (hasLegacyPackage) { | ||
// When there's a legacy installed extension, remove it first, | ||
// then also remove any new-style directory the user may have. | ||
|
@@ -334,8 +334,8 @@ function _cmdInstall(packagePath, destinationDirectory, options, callback, _doUp | |
* systemExtensionDirectory: !string}} additional settings to control the installation | ||
* @param {function} callback (err, result) | ||
*/ | ||
function _cmdUpdate(packagePath, destinationDirectory, options, callback) { | ||
_cmdInstall(packagePath, destinationDirectory, options, callback, true); | ||
function _cmdUpdate(packagePath, destinationDirectory, options, callback, pCallback) { | ||
_cmdInstall(packagePath, destinationDirectory, options, callback, pCallback, true); | ||
} | ||
|
||
/** | ||
|
@@ -375,7 +375,7 @@ function _endDownload(downloadId, error) { | |
/** | ||
* Implements "downloadFile" command, asynchronously. | ||
*/ | ||
function _cmdDownloadFile(downloadId, url, proxy, callback) { | ||
function _cmdDownloadFile(downloadId, url, proxy, callback, pCallback) { | ||
// Backwards compatibility check, added in 0.37 | ||
if (typeof proxy === "function") { | ||
callback = proxy; | ||
|
@@ -436,7 +436,7 @@ function _cmdAbortDownload(downloadId) { | |
/** | ||
* Implements the remove extension command. | ||
*/ | ||
function _cmdRemove(extensionDir, callback) { | ||
function _cmdRemove(extensionDir, callback, pCallback) { | ||
fs.remove(extensionDir, function (err) { | ||
if (err) { | ||
callback(err); | ||
|
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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