X Tutup
Skip to content

Commit 238ea29

Browse files
chore: update package.json scripts for gn build and automated releases (electron#14612)
* Removes un-used and non-functional code coverage helpers * Removes un-used release script aliases * Moves TLS to a lib folder for cleaner directory structure * Implements start.py as start.js for the GN build * Adds a re-usable getElectronExec helper for future scripts * Refactors spec runner to use the helper
1 parent 774395d commit 238ea29

File tree

8 files changed

+52
-26
lines changed

8 files changed

+52
-26
lines changed

package.json

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@
5151
"bump-version": "./script/bump-version.py",
5252
"check-tls": "python ./script/tls.py",
5353
"clang-format": "find atom/ brightray/ chromium_src/ -iname *.h -o -iname *.cc -o -iname *.mm | xargs clang-format -i",
54-
"coverage": "npm run instrument-code-coverage && npm test -- --use_instrumented_asar",
55-
"instrument-code-coverage": "electabul instrument --input-path ./lib --output-path ./out/coverage/electron.asar",
5654
"lint": "npm run lint:js && npm run lint:cpp && npm run lint:clang-format && npm run lint:py && npm run lint:docs",
5755
"lint:js": "standard && cd spec && standard",
5856
"lint:clang-format": "python script/run-clang-format.py -r -c atom/ chromium_src/ brightray/ || (echo \"\\nCode not formatted correctly.\" && exit 1)",
@@ -61,18 +59,14 @@
6159
"lint:docs": "remark docs -qf && npm run lint:js-in-markdown && npm run create-typescript-definitions && npm run lint:docs-relative-links",
6260
"lint:docs-relative-links": "python ./script/check-relative-doc-links.py",
6361
"lint:js-in-markdown": "standard-markdown docs",
64-
"create-api-json": "electron-docs-linter docs --outfile=electron-api.json --version=4.0.0-nightly.20180823",
62+
"create-api-json": "electron-docs-linter docs --outfile=electron-api.json --version=$npm_package_version",
6563
"create-typescript-definitions": "npm run create-api-json && electron-typescript-definitions --in=electron-api.json --out=electron.d.ts",
66-
"mock-release": "node ./script/ci-release-build.js",
6764
"preinstall": "node -e 'process.exit(0)'",
68-
"publish-to-npm": "node ./script/publish-to-npm.js",
6965
"precommit": "python script/run-clang-format.py -r -c atom/ chromium_src/ brightray/ && node ./script/cpplint.js -c && npm run lint:js && remark docs -qf || (echo \"Code not formatted correctly.\" && exit 1)",
7066
"prepack": "check-for-leaks",
7167
"prepush": "check-for-leaks",
72-
"prepare-release": "node ./script/prepare-release.js",
73-
"release": "node ./script/release.js",
74-
"repl": "python ./script/start.py --interactive",
75-
"start": "python ./script/start.py",
68+
"repl": "node ./script/start.js --interactive",
69+
"start": "node ./script/start.js",
7670
"test": "node ./script/spec-runner.js electron/spec"
7771
},
7872
"license": "MIT",
File renamed without changes.

script/lib/utils.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
const OUT_DIR = process.env.ELECTRON_OUT_DIR || 'Default'
2+
3+
const path = require('path')
4+
5+
function getElectronExec () {
6+
switch (process.platform) {
7+
case 'darwin':
8+
return `out/${OUT_DIR}/Electron.app/Contents/MacOS/Electron`
9+
case 'win32':
10+
return `out/${OUT_DIR}/electron.exe`
11+
case 'linux':
12+
return `out/${OUT_DIR}/electron`
13+
default:
14+
throw new Error('Unknown platform')
15+
}
16+
}
17+
18+
function getAbsoluteElectronExec () {
19+
return path.resolve(__dirname, '../../..', getElectronExec())
20+
}
21+
22+
module.exports = {
23+
getElectronExec,
24+
getAbsoluteElectronExec,
25+
OUT_DIR
26+
}

script/spec-runner.js

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ const fs = require('fs')
44
const { hashElement } = require('folder-hash')
55
const path = require('path')
66

7+
const utils = require('./lib/utils')
8+
79
const BASE = path.resolve(__dirname, '../..')
810
const NPM_CMD = process.platform === 'win32' ? 'npm.cmd' : 'npm'
9-
const OUT_DIR = process.env.ELECTRON_SPEC_OUT_DIR || 'Default'
1011

1112
const specHashPath = path.resolve(__dirname, '../spec/.hash')
1213

@@ -20,7 +21,7 @@ getSpecHash().then(([currentSpecHash, currentSpecInstallHash]) => {
2021
if (specChanged || installChanged) {
2122
const out = cp.spawnSync(NPM_CMD, ['install'], {
2223
env: Object.assign({}, process.env, {
23-
npm_config_nodedir: path.resolve(BASE, `out/${OUT_DIR}/gen/node_headers`),
24+
npm_config_nodedir: path.resolve(BASE, `out/${utils.OUT_DIR}/gen/node_headers`),
2425
npm_config_msvs_version: '2017'
2526
}),
2627
cwd: path.resolve(__dirname, '../spec')
@@ -35,7 +36,7 @@ getSpecHash().then(([currentSpecHash, currentSpecInstallHash]) => {
3536
})
3637
}
3738
}).then(() => {
38-
let exe = path.resolve(BASE, getElectronExec())
39+
let exe = path.resolve(BASE, utils.getElectronExec())
3940
const args = process.argv.slice(2)
4041
if (process.platform === 'linux') {
4142
args.unshift(path.resolve(__dirname, 'lib/dbus_mock.py'), exe)
@@ -50,19 +51,6 @@ getSpecHash().then(([currentSpecHash, currentSpecInstallHash]) => {
5051
})
5152
})
5253

53-
function getElectronExec () {
54-
switch (process.platform) {
55-
case 'darwin':
56-
return 'out/Default/Electron.app/Contents/MacOS/Electron'
57-
case 'win32':
58-
return 'out/Default/electron.exe'
59-
case 'linux':
60-
return 'out/Default/electron'
61-
default:
62-
throw new Error('Unknown path')
63-
}
64-
}
65-
6654
function getSpecHash () {
6755
return Promise.all([
6856
new Promise((resolve) => {

script/start.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
const cp = require('child_process')
2+
3+
const utils = require('./lib/utils')
4+
5+
const electronPath = utils.getAbsoluteElectronExec()
6+
7+
var child = cp.spawn(electronPath, process.argv.slice(2), { stdio: 'inherit' })
8+
child.on('close', (code) => process.exit(code))
9+
10+
const handleTerminationSignal = (signal) =>
11+
process.on(signal, () => {
12+
if (!child.killed) {
13+
child.kill(signal)
14+
}
15+
})
16+
17+
handleTerminationSignal('SIGINT')
18+
handleTerminationSignal('SIGTERM')

script/tls.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
def check_tls(verbose):
1515
process = subprocess.Popen(
16-
'node tls.js',
16+
'node lib/tls',
1717
cwd=os.path.dirname(os.path.realpath(__file__)),
1818
shell=True,
1919
stdout=subprocess.PIPE,

0 commit comments

Comments
 (0)
X Tutup