1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/devtools/gcli/commands/tools.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,87 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +"use strict"; 1.9 + 1.10 +const { Cc, Ci, Cu } = require("chrome"); 1.11 +const Services = require("Services"); 1.12 +const { OS } = require("resource://gre/modules/osfile.jsm"); 1.13 +const { devtools } = require("resource://gre/modules/devtools/Loader.jsm"); 1.14 +const gcli = require("gcli/index"); 1.15 + 1.16 +const BRAND_SHORT_NAME = Cc["@mozilla.org/intl/stringbundle;1"] 1.17 + .getService(Ci.nsIStringBundleService) 1.18 + .createBundle("chrome://branding/locale/brand.properties") 1.19 + .GetStringFromName("brandShortName"); 1.20 + 1.21 +exports.items = [ 1.22 + { 1.23 + name: "tools", 1.24 + description: gcli.lookupFormat("toolsDesc2", [ BRAND_SHORT_NAME ]), 1.25 + manual: gcli.lookupFormat("toolsManual2", [ BRAND_SHORT_NAME ]), 1.26 + get hidden() gcli.hiddenByChromePref(), 1.27 + }, 1.28 + { 1.29 + name: "tools srcdir", 1.30 + description: gcli.lookup("toolsSrcdirDesc"), 1.31 + manual: gcli.lookupFormat("toolsSrcdirManual2", [ BRAND_SHORT_NAME ]), 1.32 + get hidden() gcli.hiddenByChromePref(), 1.33 + params: [ 1.34 + { 1.35 + name: "srcdir", 1.36 + type: "string" /* { 1.37 + name: "file", 1.38 + filetype: "directory", 1.39 + existing: "yes" 1.40 + } */, 1.41 + description: gcli.lookup("toolsSrcdirDir") 1.42 + } 1.43 + ], 1.44 + returnType: "string", 1.45 + exec: function(args, context) { 1.46 + let clobber = OS.Path.join(args.srcdir, "CLOBBER"); 1.47 + return OS.File.exists(clobber).then(function(exists) { 1.48 + if (exists) { 1.49 + let str = Cc["@mozilla.org/supports-string;1"] 1.50 + .createInstance(Ci.nsISupportsString); 1.51 + str.data = args.srcdir; 1.52 + Services.prefs.setComplexValue("devtools.loader.srcdir", 1.53 + Ci.nsISupportsString, str); 1.54 + devtools.reload(); 1.55 + 1.56 + let msg = gcli.lookupFormat("toolsSrcdirReloaded", [ args.srcdir ]); 1.57 + throw new Error(msg); 1.58 + } 1.59 + 1.60 + return gcli.lookupFormat("toolsSrcdirNotFound", [ args.srcdir ]); 1.61 + }); 1.62 + } 1.63 + }, 1.64 + { 1.65 + name: "tools builtin", 1.66 + description: gcli.lookup("toolsBuiltinDesc"), 1.67 + manual: gcli.lookup("toolsBuiltinManual"), 1.68 + get hidden() gcli.hiddenByChromePref(), 1.69 + returnType: "string", 1.70 + exec: function(args, context) { 1.71 + Services.prefs.clearUserPref("devtools.loader.srcdir"); 1.72 + devtools.reload(); 1.73 + return gcli.lookup("toolsBuiltinReloaded"); 1.74 + } 1.75 + }, 1.76 + { 1.77 + name: "tools reload", 1.78 + description: gcli.lookup("toolsReloadDesc"), 1.79 + get hidden() { 1.80 + return gcli.hiddenByChromePref() || 1.81 + !Services.prefs.prefHasUserValue("devtools.loader.srcdir"); 1.82 + }, 1.83 + 1.84 + returnType: "string", 1.85 + exec: function(args, context) { 1.86 + devtools.reload(); 1.87 + return gcli.lookup("toolsReloaded2"); 1.88 + } 1.89 + } 1.90 +];