[js] Rearrange code to fix scoping on variable used in error reporting
@@ -79,6 +79,21 @@ var AddonDetails;
var RdfRoot;
+/**
+ * Extracts the details needed to install an add-on.
+ * @param {string} addonPath Path to the extension directory.
+ * @return {!Promise<!AddonDetails>} A promise for the add-on details.
+ */
+function getDetails(addonPath) {
+ return io.stat(addonPath).then((stats) => {
+ if (stats.isDirectory()) {
+ return parseDirectory(addonPath);
+ } else if (addonPath.slice(-4) === '.xpi') {
+ return parseXpiFile(addonPath);
+ } else {
+ throw Error('Add-on path is not an xpi or a directory: ' + addonPath);
+ }
+ });
/**
* Parse an install.rdf for a Firefox add-on.
@@ -148,7 +163,6 @@ function parseInstallRdf(rdf) {
}
}
-
/**
* Parse a manifest for a Firefox WebExtension.
* @param {!Object} json JSON representation of the manifest.
@@ -162,22 +176,6 @@ function parseManifestJson({name, version, applications}) {
return {id: applications.gecko.id, name, version, unpack: false};
}
-/**
- * Extracts the details needed to install an add-on.
- * @param {string} addonPath Path to the extension directory.
- * @return {!Promise<!AddonDetails>} A promise for the add-on details.
- */
-function getDetails(addonPath) {
- return io.stat(addonPath).then((stats) => {
- if (stats.isDirectory()) {
- return parseDirectory(addonPath);
- } else if (addonPath.slice(-4) === '.xpi') {
- return parseXpiFile(addonPath);
- } else {
- throw Error('Add-on path is not an xpi or a directory: ' + addonPath);
- }
- });
-
function parseXpiFile(filePath) {
const zip = new AdmZip(filePath);
