From 09b45911bc9a2f1195450c1760e00b704ab9623c Mon Sep 17 00:00:00 2001 From: David Wilson Date: Tue, 21 Aug 2018 10:54:20 -0700 Subject: [PATCH 1/3] Local package paths now use symbolic links, remove extra package install --- script/bootstrap | 24 ------------------------ script/lib/copy-assets.js | 2 +- 2 files changed, 1 insertion(+), 25 deletions(-) diff --git a/script/bootstrap b/script/bootstrap index 1abfc48d0..156ddf286 100755 --- a/script/bootstrap +++ b/script/bootstrap @@ -43,28 +43,4 @@ childProcess.execFileSync( ) runApmInstall(CONFIG.repositoryRootPath, ci) -if (!process.env.CI) { - require('colors') - const glob = require('glob') - const {spawn} = require('child_process') - - // Install the local core packages in-place so they can be used in dev mode - const files = glob.sync(path.join(CONFIG.repositoryRootPath, 'packages/*/package.json')) - if (files.length > 0) { - console.log('Installing core packages for use in dev mode...') - - files.forEach(file => { - const packageDir = path.dirname(file) - process.stdout.write(`Installing packages/${path.basename(packageDir)} `) - runApmInstall(path.dirname(file), false, ['inherit', 'pipe', 'inherit']) - - if (process.platform === 'win32') { - return process.stdout.write('done\n'.green) - } else { - return process.stdout.write('\u2713\n'.green) - } - }) - } -} - dependenciesFingerprint.write() diff --git a/script/lib/copy-assets.js b/script/lib/copy-assets.js index d53515f4a..27b5f086c 100644 --- a/script/lib/copy-assets.js +++ b/script/lib/copy-assets.js @@ -23,7 +23,7 @@ module.exports = function () { ] srcPaths = srcPaths.concat(glob.sync(path.join(CONFIG.repositoryRootPath, 'spec', '*.*'), {ignore: path.join('**', '*-spec.*')})) for (let srcPath of srcPaths) { - fs.copySync(srcPath, computeDestinationPath(srcPath), {filter: includePathInPackagedApp}) + fs.copySync(srcPath, computeDestinationPath(srcPath), {filter: includePathInPackagedApp, dereference: true}) } fs.copySync( From ba12a1e2fc12543ff49d1c9add6b997086574961 Mon Sep 17 00:00:00 2001 From: David Wilson Date: Tue, 21 Aug 2018 11:57:18 -0700 Subject: [PATCH 2/3] Simplify dev resource path detection --- src/main-process/get-dev-resource-path.js | 31 ----------------------- src/main-process/main.js | 26 +++++++++++++++++-- src/main-process/parse-command-line.js | 5 ++-- src/main-process/start.js | 4 +-- 4 files changed, 28 insertions(+), 38 deletions(-) delete mode 100644 src/main-process/get-dev-resource-path.js diff --git a/src/main-process/get-dev-resource-path.js b/src/main-process/get-dev-resource-path.js deleted file mode 100644 index fe89e58fb..000000000 --- a/src/main-process/get-dev-resource-path.js +++ /dev/null @@ -1,31 +0,0 @@ -'use strict' - -const path = require('path') -const fs = require('fs-plus') -const CSON = require('season') -const electron = require('electron') - -module.exports = function () { - const appResourcePath = path.dirname(path.dirname(__dirname)) - const defaultRepositoryPath = path.join(electron.app.getPath('home'), 'github', 'atom') - - if (process.env.ATOM_DEV_RESOURCE_PATH) { - return process.env.ATOM_DEV_RESOURCE_PATH - } else if (isAtomRepoPath(process.cwd())) { - return process.cwd() - } else if (fs.statSyncNoException(defaultRepositoryPath)) { - return defaultRepositoryPath - } - - return appResourcePath -} - -function isAtomRepoPath (repoPath) { - let packageJsonPath = path.join(repoPath, 'package.json') - if (fs.statSyncNoException(packageJsonPath)) { - let packageJson = CSON.readFileSync(packageJsonPath) - return packageJson.name === 'atom' - } - - return false -} diff --git a/src/main-process/main.js b/src/main-process/main.js index 77dacd792..ea4dac79f 100644 --- a/src/main-process/main.js +++ b/src/main-process/main.js @@ -5,8 +5,10 @@ if (typeof snapshotResult !== 'undefined') { const startTime = Date.now() const path = require('path') +const fs = require('fs-plus') +const CSON = require('season') const yargs = require('yargs') -const getDevResourcePath = require('./get-dev-resource-path') +const electron = require('electron') const args = yargs(process.argv) @@ -14,14 +16,34 @@ const args = .alias('t', 'test') .argv +function isAtomRepoPath (repoPath) { + let packageJsonPath = path.join(repoPath, 'package.json') + if (fs.statSyncNoException(packageJsonPath)) { + let packageJson = CSON.readFileSync(packageJsonPath) + return packageJson.name === 'atom' + } + + return false +} + let resourcePath if (args.resourcePath) { resourcePath = args.resourcePath } else { const stableResourcePath = path.dirname(path.dirname(__dirname)) + const defaultRepositoryPath = path.join(electron.app.getPath('home'), 'github', 'atom') + if (args.dev || args.test || args.benchmark || args.benchmarkTest) { - resourcePath = getDevResourcePath() || stableResourcePath + 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 + } } else { resourcePath = stableResourcePath } diff --git a/src/main-process/parse-command-line.js b/src/main-process/parse-command-line.js index 1d25fe70c..809971e85 100644 --- a/src/main-process/parse-command-line.js +++ b/src/main-process/parse-command-line.js @@ -5,9 +5,8 @@ const yargs = require('yargs') const {app} = require('electron') const path = require('path') const fs = require('fs-plus') -const getDevResourcePath = require('./get-dev-resource-path') -module.exports = function parseCommandLine (processArgs) { +module.exports = function parseCommandLine (processArgs, initialResourcePath) { const options = yargs(processArgs).wrap(yargs.terminalWidth()) const version = app.getVersion() options.usage( @@ -120,7 +119,7 @@ module.exports = function parseCommandLine (processArgs) { let pathsToOpen = [] let urlsToOpen = [] let devMode = args['dev'] - let devResourcePath = getDevResourcePath() + let devResourcePath = initialResourcePath let resourcePath = null for (const path of args._) { diff --git a/src/main-process/start.js b/src/main-process/start.js index 25bc9c00d..460b58e6e 100644 --- a/src/main-process/start.js +++ b/src/main-process/start.js @@ -9,7 +9,7 @@ const fs = require('fs') const CSON = require('season') const Config = require('../config') -module.exports = function start (resourcePath, startTime) { +module.exports = function start (initialResourcePath, startTime) { global.shellStartTime = startTime process.on('uncaughtException', function (error = {}) { @@ -37,7 +37,7 @@ module.exports = function start (resourcePath, startTime) { app.commandLine.appendSwitch('enable-experimental-web-platform-features') - const args = parseCommandLine(process.argv.slice(1)) + const args = parseCommandLine(process.argv.slice(1), initialResourcePath) atomPaths.setAtomHome(app.getPath('home')) atomPaths.setUserData(app) setupCompileCache() From 2d65535147d1d5a4454c6be6619850b598de388e Mon Sep 17 00:00:00 2001 From: David Wilson Date: Tue, 21 Aug 2018 14:20:42 -0700 Subject: [PATCH 3/3] Don't normalize undefined devResourcePath on Windows --- src/main-process/parse-command-line.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main-process/parse-command-line.js b/src/main-process/parse-command-line.js index 809971e85..55aa7c900 100644 --- a/src/main-process/parse-command-line.js +++ b/src/main-process/parse-command-line.js @@ -183,7 +183,7 @@ module.exports = function parseCommandLine (processArgs, initialResourcePath) { } function normalizeDriveLetterName (filePath) { - if (process.platform === 'win32') { + if (process.platform === 'win32' && filePath) { return filePath.replace(/^([a-z]):/, ([driveLetter]) => driveLetter.toUpperCase() + ':') } else { return filePath