From e14ffb94203d42fb5ca034965635868ee5aae483 Mon Sep 17 00:00:00 2001 From: Philip Weiss Date: Fri, 9 Mar 2018 14:04:21 -0800 Subject: [PATCH] set default path inside of project.replace --- src/main-process/atom-application.js | 2 +- src/main-process/parse-command-line.js | 13 ++++++++----- src/project.js | 8 ++++++++ 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/main-process/atom-application.js b/src/main-process/atom-application.js index 2f935d35c..10b791761 100644 --- a/src/main-process/atom-application.js +++ b/src/main-process/atom-application.js @@ -855,7 +855,7 @@ class AtomApplication extends EventEmitter { } let openedWindow - if (existingWindow && projectSpecification.paths == null && projectSpecification.config == null) { + if (existingWindow && (projectSpecification == null || projectSpecification.config == null)) { openedWindow = existingWindow openedWindow.openLocations(locationsToOpen) if (openedWindow.isMinimized()) { diff --git a/src/main-process/parse-command-line.js b/src/main-process/parse-command-line.js index d811cd0e8..ddcef09f5 100644 --- a/src/main-process/parse-command-line.js +++ b/src/main-process/parse-command-line.js @@ -146,11 +146,16 @@ module.exports = function parseCommandLine (processArgs) { const contents = Object.assign({}, readProjectSpecificationSync(readPath, executedFrom)) const pathToProjectFile = path.join(executedFrom, projectSpecificationFile) + const base = path.dirname(pathToProjectFile) pathsToOpen.push(path.dirname(projectSpecificationFile)) + const paths = (contents.paths == null) + ? undefined + : contents.paths.map(curPath => path.resolve(base, curPath)) + projectSpecification = { - originPath: projectSpecificationFile, - paths: contents.paths.map(curPath => path.resolve(base, curPath)), + originPath: pathToProjectFile, + paths, config: contents.config } } @@ -171,6 +176,7 @@ module.exports = function parseCommandLine (processArgs) { resourcePath = normalizeDriveLetterName(resourcePath) devResourcePath = normalizeDriveLetterName(devResourcePath) + return { projectSpecification, resourcePath, @@ -206,9 +212,6 @@ function readProjectSpecificationSync (filepath, executedFrom) { throw new Error('Unable to read supplied project specification file.') } - if (contents.paths == null) { - contents.paths = [path.dirname(filepath)] - } contents.config = (contents.config == null) ? {} : contents.config return contents } diff --git a/src/project.js b/src/project.js index 6f1900dab..7d8a8cd24 100644 --- a/src/project.js +++ b/src/project.js @@ -84,6 +84,14 @@ class Project extends Model { atom.config.clearProjectSettings() this.setPaths([]) } else { + if (projectSpecification.originPath == null) { + return + } + + // If no path is specified, set to directory of originPath. + if (!Array.isArray(projectSpecification.paths)) { + projectSpecification.paths = [path.dirname(projectSpecification.originPath)] + } atom.config.resetProjectSettings(projectSpecification.config, projectSpecification.originPath) this.setPaths(projectSpecification.paths) }