[*] 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
This commit is contained in:
Mark Hahnenberg 2017-02-17 11:43:09 -08:00
parent c4a26e1dcd
commit a95ca8b07a

View file

@ -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:')) {