diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /devtools/shared/gcli/commands/folder.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'devtools/shared/gcli/commands/folder.js')
-rw-r--r-- | devtools/shared/gcli/commands/folder.js | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/devtools/shared/gcli/commands/folder.js b/devtools/shared/gcli/commands/folder.js new file mode 100644 index 000000000..22a51420d --- /dev/null +++ b/devtools/shared/gcli/commands/folder.js @@ -0,0 +1,77 @@ +/* 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, CC } = require("chrome"); +const Services = require("Services"); +const l10n = require("gcli/l10n"); +const dirService = Cc["@mozilla.org/file/directory_service;1"] + .getService(Ci.nsIProperties); + +function showFolder(aPath) { + let nsLocalFile = CC("@mozilla.org/file/local;1", "nsILocalFile", + "initWithPath"); + + try { + let file = new nsLocalFile(aPath); + + if (file.exists()) { + file.reveal(); + return l10n.lookupFormat("folderOpenDirResult", [aPath]); + } else { + return l10n.lookup("folderInvalidPath"); + } + } catch (e) { + return l10n.lookup("folderInvalidPath"); + } +} + +exports.items = [ + { + name: "folder", + description: l10n.lookup("folderDesc") + }, + { + item: "command", + runAt: "client", + name: "folder open", + description: l10n.lookup("folderOpenDesc"), + params: [ + { + name: "path", + type: { name: "string", allowBlank: true }, + defaultValue: "~", + description: l10n.lookup("folderOpenDir") + } + ], + returnType: "string", + exec: function(args, context) { + let dirName = args.path; + + // replaces ~ with the home directory path in unix and windows + if (dirName.indexOf("~") == 0) { + let homeDirFile = dirService.get("Home", Ci.nsIFile); + let homeDir = homeDirFile.path; + dirName = dirName.substr(1); + dirName = homeDir + dirName; + } + + return showFolder(dirName); + } + }, + { + item: "command", + runAt: "client", + name: "folder openprofile", + description: l10n.lookup("folderOpenProfileDesc"), + returnType: "string", + exec: function(args, context) { + // Get the profile directory. + let currProfD = Services.dirsvc.get("ProfD", Ci.nsIFile); + let profileDir = currProfD.path; + return showFolder(profileDir); + } + } +]; |