This repository has been archived by the owner on Mar 3, 2023. It is now read-only.
/
main.js
57 lines (47 loc) · 1.57 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
if (typeof snapshotResult !== 'undefined') {
snapshotResult.setGlobals(global, process, global, {}, console, require)
}
const startTime = Date.now()
const path = require('path')
const fs = require('fs-plus')
const CSON = require('season')
const yargs = require('yargs')
const electron = require('electron')
const args =
yargs(process.argv)
.alias('d', 'dev')
.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
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) {
resourcePath = devResourcePath
} else {
resourcePath = stableResourcePath
}
}
const start = require(path.join(resourcePath, 'src', 'main-process', 'start'))
start(resourcePath, devResourcePath, startTime)