From a95ca8b07afd1e57c380f9a2c9644e4cde1f6260 Mon Sep 17 00:00:00 2001 From: Mark Hahnenberg Date: Fri, 17 Feb 2017 11:43:09 -0800 Subject: [PATCH] [*] Fix electron launch args Summary: We were doing some incorrect processing of args passed to the main function which was causing us to think we were launching NM by passing a file (which creates a new draft and tries to attach that file). Since were trying to attach 'packages/client-app', this was causing an error dialogue to appear indicating that it wasn't possible to attach a directory. Test Plan: Run locally, verify no dialogue Reviewers: evan, spang, juan Reviewed By: juan Differential Revision: https://phab.nylas.com/D3962 --- packages/client-app/src/browser/main.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/client-app/src/browser/main.js b/packages/client-app/src/browser/main.js index 74621174f..ed6e81abc 100644 --- a/packages/client-app/src/browser/main.js +++ b/packages/client-app/src/browser/main.js @@ -93,15 +93,15 @@ const parseCommandLine = (argv) => { const specDirectory = args['spec-directory']; const specFilePattern = args['spec-file-pattern']; const showSpecsInWindow = specMode === "window"; - const resourcePath = path.resolve(args['resource-path'] != null ? args['resource-path'] : path.dirname(path.dirname(__dirname))); + const resourcePath = path.resolve(path.dirname(path.dirname(__dirname))); const urlsToOpen = []; const pathsToOpen = []; // On Windows and Linux, mailto and file opens are passed in argv. Go through // the items and pluck out things that look like mailto:, nylas:, file paths let ignoreNext = false; - for (let i = 1; i < argv.length; i ++) { - const arg = argv[i]; + // args._ is all of the non-hyphenated options. + for (const arg of args._) { if (ignoreNext) { ignoreNext = false; continue; @@ -110,7 +110,8 @@ const parseCommandLine = (argv) => { ignoreNext = true; continue; } - if (arg === resourcePath) { + // Skip the argument if it's part of the main electron invocation. + if (path.resolve(arg) === resourcePath) { continue; } if (arg.startsWith('mailto:') || arg.startsWith('nylas:')) {