toolkit/devtools/gcli/commands/tools.js

branch
TOR_BUG_3246
changeset 7
129ffea94266
equal deleted inserted replaced
-1:000000000000 0:8bef618020fb
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5 "use strict";
6
7 const { Cc, Ci, Cu } = require("chrome");
8 const Services = require("Services");
9 const { OS } = require("resource://gre/modules/osfile.jsm");
10 const { devtools } = require("resource://gre/modules/devtools/Loader.jsm");
11 const gcli = require("gcli/index");
12
13 const BRAND_SHORT_NAME = Cc["@mozilla.org/intl/stringbundle;1"]
14 .getService(Ci.nsIStringBundleService)
15 .createBundle("chrome://branding/locale/brand.properties")
16 .GetStringFromName("brandShortName");
17
18 exports.items = [
19 {
20 name: "tools",
21 description: gcli.lookupFormat("toolsDesc2", [ BRAND_SHORT_NAME ]),
22 manual: gcli.lookupFormat("toolsManual2", [ BRAND_SHORT_NAME ]),
23 get hidden() gcli.hiddenByChromePref(),
24 },
25 {
26 name: "tools srcdir",
27 description: gcli.lookup("toolsSrcdirDesc"),
28 manual: gcli.lookupFormat("toolsSrcdirManual2", [ BRAND_SHORT_NAME ]),
29 get hidden() gcli.hiddenByChromePref(),
30 params: [
31 {
32 name: "srcdir",
33 type: "string" /* {
34 name: "file",
35 filetype: "directory",
36 existing: "yes"
37 } */,
38 description: gcli.lookup("toolsSrcdirDir")
39 }
40 ],
41 returnType: "string",
42 exec: function(args, context) {
43 let clobber = OS.Path.join(args.srcdir, "CLOBBER");
44 return OS.File.exists(clobber).then(function(exists) {
45 if (exists) {
46 let str = Cc["@mozilla.org/supports-string;1"]
47 .createInstance(Ci.nsISupportsString);
48 str.data = args.srcdir;
49 Services.prefs.setComplexValue("devtools.loader.srcdir",
50 Ci.nsISupportsString, str);
51 devtools.reload();
52
53 let msg = gcli.lookupFormat("toolsSrcdirReloaded", [ args.srcdir ]);
54 throw new Error(msg);
55 }
56
57 return gcli.lookupFormat("toolsSrcdirNotFound", [ args.srcdir ]);
58 });
59 }
60 },
61 {
62 name: "tools builtin",
63 description: gcli.lookup("toolsBuiltinDesc"),
64 manual: gcli.lookup("toolsBuiltinManual"),
65 get hidden() gcli.hiddenByChromePref(),
66 returnType: "string",
67 exec: function(args, context) {
68 Services.prefs.clearUserPref("devtools.loader.srcdir");
69 devtools.reload();
70 return gcli.lookup("toolsBuiltinReloaded");
71 }
72 },
73 {
74 name: "tools reload",
75 description: gcli.lookup("toolsReloadDesc"),
76 get hidden() {
77 return gcli.hiddenByChromePref() ||
78 !Services.prefs.prefHasUserValue("devtools.loader.srcdir");
79 },
80
81 returnType: "string",
82 exec: function(args, context) {
83 devtools.reload();
84 return gcli.lookup("toolsReloaded2");
85 }
86 }
87 ];

mercurial