mirror of
https://github.com/atom/atom.git
synced 2026-01-26 15:28:27 -05:00
Merge pull request #17903 from atom/dw-fix-dev-resource-path
Always provide a devResourcePath in load settings
This commit is contained in:
@@ -14,6 +14,7 @@ const args =
|
||||
yargs(process.argv)
|
||||
.alias('d', 'dev')
|
||||
.alias('t', 'test')
|
||||
.alias('r', 'resource-path')
|
||||
.argv
|
||||
|
||||
function isAtomRepoPath (repoPath) {
|
||||
@@ -27,27 +28,31 @@ function isAtomRepoPath (repoPath) {
|
||||
}
|
||||
|
||||
let resourcePath
|
||||
let devResourcePath
|
||||
|
||||
if (args.resourcePath) {
|
||||
resourcePath = args.resourcePath
|
||||
devResourcePath = resourcePath
|
||||
} else {
|
||||
const stableResourcePath = path.dirname(path.dirname(__dirname))
|
||||
const defaultRepositoryPath = path.join(electron.app.getPath('home'), 'github', 'atom')
|
||||
|
||||
if (process.env.ATOM_DEV_RESOURCE_PATH) {
|
||||
devResourcePath = process.env.ATOM_DEV_RESOURCE_PATH
|
||||
} else if (isAtomRepoPath(process.cwd())) {
|
||||
devResourcePath = process.cwd()
|
||||
} else if (fs.statSyncNoException(defaultRepositoryPath)) {
|
||||
devResourcePath = defaultRepositoryPath
|
||||
} else {
|
||||
devResourcePath = stableResourcePath
|
||||
}
|
||||
|
||||
if (args.dev || args.test || args.benchmark || args.benchmarkTest) {
|
||||
if (process.env.ATOM_DEV_RESOURCE_PATH) {
|
||||
resourcePath = process.env.ATOM_DEV_RESOURCE_PATH
|
||||
} else if (isAtomRepoPath(process.cwd())) {
|
||||
resourcePath = process.cwd()
|
||||
} else if (fs.statSyncNoException(defaultRepositoryPath)) {
|
||||
resourcePath = defaultRepositoryPath
|
||||
} else {
|
||||
resourcePath = stableResourcePath
|
||||
}
|
||||
resourcePath = devResourcePath
|
||||
} else {
|
||||
resourcePath = stableResourcePath
|
||||
}
|
||||
}
|
||||
|
||||
const start = require(path.join(resourcePath, 'src', 'main-process', 'start'))
|
||||
start(resourcePath, startTime)
|
||||
start(resourcePath, devResourcePath, startTime)
|
||||
|
||||
@@ -3,10 +3,8 @@
|
||||
const dedent = require('dedent')
|
||||
const yargs = require('yargs')
|
||||
const {app} = require('electron')
|
||||
const path = require('path')
|
||||
const fs = require('fs-plus')
|
||||
|
||||
module.exports = function parseCommandLine (processArgs, initialResourcePath) {
|
||||
module.exports = function parseCommandLine (processArgs) {
|
||||
const options = yargs(processArgs).wrap(yargs.terminalWidth())
|
||||
const version = app.getVersion()
|
||||
options.usage(
|
||||
@@ -119,8 +117,6 @@ module.exports = function parseCommandLine (processArgs, initialResourcePath) {
|
||||
let pathsToOpen = []
|
||||
let urlsToOpen = []
|
||||
let devMode = args['dev']
|
||||
let devResourcePath = initialResourcePath
|
||||
let resourcePath = null
|
||||
|
||||
for (const path of args._) {
|
||||
if (path.startsWith('atom://')) {
|
||||
@@ -130,21 +126,8 @@ module.exports = function parseCommandLine (processArgs, initialResourcePath) {
|
||||
}
|
||||
}
|
||||
|
||||
if (args['resource-path']) {
|
||||
if (args.resourcePath || test) {
|
||||
devMode = true
|
||||
devResourcePath = args['resource-path']
|
||||
}
|
||||
|
||||
if (test) {
|
||||
devMode = true
|
||||
}
|
||||
|
||||
if (devMode) {
|
||||
resourcePath = devResourcePath
|
||||
}
|
||||
|
||||
if (!fs.statSyncNoException(resourcePath)) {
|
||||
resourcePath = path.dirname(path.dirname(__dirname))
|
||||
}
|
||||
|
||||
if (args['path-environment']) {
|
||||
@@ -153,12 +136,7 @@ module.exports = function parseCommandLine (processArgs, initialResourcePath) {
|
||||
process.env.PATH = args['path-environment']
|
||||
}
|
||||
|
||||
resourcePath = normalizeDriveLetterName(resourcePath)
|
||||
devResourcePath = normalizeDriveLetterName(devResourcePath)
|
||||
|
||||
return {
|
||||
resourcePath,
|
||||
devResourcePath,
|
||||
pathsToOpen,
|
||||
urlsToOpen,
|
||||
executedFrom,
|
||||
@@ -181,11 +159,3 @@ module.exports = function parseCommandLine (processArgs, initialResourcePath) {
|
||||
env: process.env
|
||||
}
|
||||
}
|
||||
|
||||
function normalizeDriveLetterName (filePath) {
|
||||
if (process.platform === 'win32' && filePath) {
|
||||
return filePath.replace(/^([a-z]):/, ([driveLetter]) => driveLetter.toUpperCase() + ':')
|
||||
} else {
|
||||
return filePath
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ const fs = require('fs')
|
||||
const CSON = require('season')
|
||||
const Config = require('../config')
|
||||
|
||||
module.exports = function start (initialResourcePath, startTime) {
|
||||
module.exports = function start (resourcePath, devResourcePath, startTime) {
|
||||
global.shellStartTime = startTime
|
||||
|
||||
process.on('uncaughtException', function (error = {}) {
|
||||
@@ -37,7 +37,10 @@ module.exports = function start (initialResourcePath, startTime) {
|
||||
|
||||
app.commandLine.appendSwitch('enable-experimental-web-platform-features')
|
||||
|
||||
const args = parseCommandLine(process.argv.slice(1), initialResourcePath)
|
||||
const args = parseCommandLine(process.argv.slice(1))
|
||||
args.resourcePath = normalizeDriveLetterName(resourcePath)
|
||||
args.devResourcePath = normalizeDriveLetterName(devResourcePath)
|
||||
|
||||
atomPaths.setAtomHome(app.getPath('home'))
|
||||
atomPaths.setUserData(app)
|
||||
setupCompileCache()
|
||||
@@ -124,3 +127,11 @@ function getConfig () {
|
||||
|
||||
return config
|
||||
}
|
||||
|
||||
function normalizeDriveLetterName (filePath) {
|
||||
if (process.platform === 'win32' && filePath) {
|
||||
return filePath.replace(/^([a-z]):/, ([driveLetter]) => driveLetter.toUpperCase() + ':')
|
||||
} else {
|
||||
return filePath
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user