gecko-dev/devtools/shared/gcli/commands/tools.js
J. Ryan Stinnett efe328f1b2 Bug 912121 - Rewrite require / import to match source tree. rs=devtools
In a following patch, all DevTools moz.build files will use DevToolsModules to
install JS modules at a path that corresponds directly to their source tree
location.  Here we rewrite all require and import calls to match the new
location that these files are installed to.

--HG--
extra : commitid : F2ItGm8ptRz
extra : rebase_source : b082fe4bf77e22e297e303fc601165ceff1c4cbc
2015-09-21 12:04:18 -05:00

100 lines
3.0 KiB
JavaScript

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
const { Cc, Ci, Cu } = require("chrome");
const Services = require("Services");
const { OS } = require("resource://gre/modules/osfile.jsm");
const { devtools } = require("resource://gre/modules/devtools/shared/Loader.jsm");
const gcli = require("gcli/index");
const l10n = require("gcli/l10n");
const BRAND_SHORT_NAME = Cc["@mozilla.org/intl/stringbundle;1"]
.getService(Ci.nsIStringBundleService)
.createBundle("chrome://branding/locale/brand.properties")
.GetStringFromName("brandShortName");
exports.items = [
{
name: "tools",
description: l10n.lookupFormat("toolsDesc2", [ BRAND_SHORT_NAME ]),
manual: l10n.lookupFormat("toolsManual2", [ BRAND_SHORT_NAME ]),
get hidden() {
return gcli.hiddenByChromePref();
}
},
{
item: "command",
runAt: "client",
name: "tools srcdir",
description: l10n.lookup("toolsSrcdirDesc"),
manual: l10n.lookupFormat("toolsSrcdirManual2", [ BRAND_SHORT_NAME ]),
get hidden() {
return gcli.hiddenByChromePref();
},
params: [
{
name: "srcdir",
type: "string" /* {
name: "file",
filetype: "directory",
existing: "yes"
} */,
description: l10n.lookup("toolsSrcdirDir")
}
],
returnType: "string",
exec: function(args, context) {
let clobber = OS.Path.join(args.srcdir, "CLOBBER");
return OS.File.exists(clobber).then(function(exists) {
if (exists) {
let str = Cc["@mozilla.org/supports-string;1"]
.createInstance(Ci.nsISupportsString);
str.data = args.srcdir;
Services.prefs.setComplexValue("devtools.loader.srcdir",
Ci.nsISupportsString, str);
devtools.reload();
return l10n.lookupFormat("toolsSrcdirReloaded2", [ args.srcdir ]);
}
return l10n.lookupFormat("toolsSrcdirNotFound2", [ args.srcdir ]);
});
}
},
{
item: "command",
runAt: "client",
name: "tools builtin",
description: l10n.lookup("toolsBuiltinDesc"),
manual: l10n.lookup("toolsBuiltinManual"),
get hidden() {
return gcli.hiddenByChromePref();
},
returnType: "string",
exec: function(args, context) {
Services.prefs.clearUserPref("devtools.loader.srcdir");
devtools.reload();
return l10n.lookup("toolsBuiltinReloaded");
}
},
{
item: "command",
runAt: "client",
name: "tools reload",
description: l10n.lookup("toolsReloadDesc"),
get hidden() {
return gcli.hiddenByChromePref() ||
!Services.prefs.prefHasUserValue("devtools.loader.srcdir");
},
returnType: "string",
exec: function(args, context) {
devtools.reload();
return l10n.lookup("toolsReloaded2");
}
}
];