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