From 8ef9dabffa2c6bf34941d37143fa73d578ca515c Mon Sep 17 00:00:00 2001 From: David Reiss Date: Mon, 18 Sep 2017 12:08:10 -0700 Subject: [PATCH] Allow atom:// urls to be opened from the command line Some Atom extensions (like Nuclide) have functionality that can only be triggered by open-url events, which only work on Mac OS. With this change, `atom://` URLs can be passed on the command-line, and they will opened with the normal openUrl method on all platforms. This change doesn't set Atom up as the default handler for atom:// urls. That will require some platform-specific changes. --- src/main-process/parse-command-line.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main-process/parse-command-line.js b/src/main-process/parse-command-line.js index 7531e609b..6c5349437 100644 --- a/src/main-process/parse-command-line.js +++ b/src/main-process/parse-command-line.js @@ -19,6 +19,8 @@ module.exports = function parseCommandLine (processArgs) { will be opened in that window. Otherwise, they will be opened in a new window. + Paths that start with \`atom://\` will be interpreted as URLs. + Environment Variables: ATOM_DEV_RESOURCE_PATH The path from which Atom loads source code in dev mode. @@ -76,7 +78,6 @@ module.exports = function parseCommandLine (processArgs) { const addToLastWindow = args['add'] const safeMode = args['safe'] - const pathsToOpen = args._ const benchmark = args['benchmark'] const benchmarkTest = args['benchmark-test'] const test = args['test'] @@ -100,11 +101,20 @@ module.exports = function parseCommandLine (processArgs) { const userDataDir = args['user-data-dir'] const profileStartup = args['profile-startup'] const clearWindowState = args['clear-window-state'] + const pathsToOpen = [] const urlsToOpen = [] let devMode = args['dev'] let devResourcePath = process.env.ATOM_DEV_RESOURCE_PATH || path.join(app.getPath('home'), 'github', 'atom') let resourcePath = null + for (const path of args._) { + if (path.startsWith('atom://')) { + urlsToOpen.push(path) + } else { + pathsToOpen.push(path) + } + } + if (args['resource-path']) { devMode = true devResourcePath = args['resource-path']