mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-20 22:47:59 +01:00
[bootstrap] Fix command line handling.
--HG-- branch : bootstrapped
This commit is contained in:
40
common/bootstrap.js
vendored
40
common/bootstrap.js
vendored
@@ -40,6 +40,7 @@ let initialized = false;
|
|||||||
let addon = null;
|
let addon = null;
|
||||||
let basePath = null;
|
let basePath = null;
|
||||||
let components = {};
|
let components = {};
|
||||||
|
let getURI = null;
|
||||||
|
|
||||||
function startup(data, reason) {
|
function startup(data, reason) {
|
||||||
dump("dactyl: bootstrap: startup\n");
|
dump("dactyl: bootstrap: startup\n");
|
||||||
@@ -50,17 +51,24 @@ function startup(data, reason) {
|
|||||||
|
|
||||||
dump("dactyl: bootstrap: init" + " " + data.id + "\n");
|
dump("dactyl: bootstrap: init" + " " + data.id + "\n");
|
||||||
|
|
||||||
AddonManager.getAddonByID(data.id, function (res) {
|
addon = data;
|
||||||
try {
|
|
||||||
addon = res;
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
dump("dactyl: bootstrap: " + e + "\n");
|
|
||||||
Cu.reportError(e);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
if (basePath.isDirectory())
|
||||||
|
getURI = function getURI(path) {
|
||||||
|
let file = basePath.clone().QueryInterface(Ci.nsILocalFile);
|
||||||
|
file.appendRelativePath(path);
|
||||||
|
return (Services.io || services.io).newFileURI(file);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
getURI = function getURI(path)
|
||||||
|
Services.io.newURI("jar:" + Services.io.newFileURI(file).spec + "!" + path);
|
||||||
|
try {
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
dump("dactyl: bootstrap: " + e + "\n" + e.stack);
|
||||||
|
Cu.reportError(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,15 +103,15 @@ FactoryProxy.prototype = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
dump("dactyl: bootstrap: init: " + addon + "\n");
|
dump("dactyl: bootstrap: init\n");
|
||||||
|
|
||||||
let manifestURI = addon.getResourceURI("chrome.manifest");
|
let manifestURI = getURI("chrome.manifest");
|
||||||
let manifest = httpGet(manifestURI.spec)
|
let manifest = httpGet(manifestURI.spec)
|
||||||
.responseText
|
.responseText
|
||||||
.replace(/^\s*|\s*$|#.*/g, "")
|
.replace(/^\s*|\s*$|#.*/g, "")
|
||||||
.replace(/^\s*\n/gm, "");
|
.replace(/^\s*\n/gm, "");
|
||||||
|
|
||||||
function url(path) addon.getResourceURI(path).spec;
|
function url(path) getURI(path).spec;
|
||||||
|
|
||||||
let result = [];
|
let result = [];
|
||||||
|
|
||||||
@@ -134,7 +142,7 @@ function init() {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case "resource":
|
case "resource":
|
||||||
resourceProto.setSubstitution(fields[1], addon.getResourceURI(fields[2]));
|
resourceProto.setSubstitution(fields[1], getURI(fields[2]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -155,13 +163,15 @@ function init() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let manifestText = result.map(function (line) line.join(" ")).join("\n");
|
||||||
|
|
||||||
if (manifestURI instanceof Ci.nsIFileURL)
|
if (manifestURI instanceof Ci.nsIFileURL)
|
||||||
manager.autoRegister(manifestURI.QueryInterface(Ci.nsIFileURL).file);
|
manager.autoRegister(manifestURI.QueryInterface(Ci.nsIFileURL).file);
|
||||||
else {
|
else {
|
||||||
var file = basePath.parent;
|
var file = basePath.parent;
|
||||||
file.append(addon.id + ".manifest");
|
file.append(addon.id + ".manifest");
|
||||||
|
|
||||||
writeFile(file, result.map(function (line) line.join(" ")).join("\n"));
|
writeFile(file, manifestText);
|
||||||
manager.autoRegister(file);
|
manager.autoRegister(file);
|
||||||
file.remove(false);
|
file.remove(false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,6 +62,8 @@ const Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase),
|
|||||||
mod.destroy();
|
mod.destroy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for (let name in values(Object.getOwnPropertyNames(modules).reverse()))
|
||||||
|
delete modules[name];
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user