chore: update package.json scripts for gn build and automated releases (#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
This commit is contained in:
parent
774395d910
commit
238ea29fa8
8 changed files with 52 additions and 26 deletions
26
script/lib/utils.js
Normal file
26
script/lib/utils.js
Normal file
|
@ -0,0 +1,26 @@
|
|||
const OUT_DIR = process.env.ELECTRON_OUT_DIR || 'Default'
|
||||
|
||||
const path = require('path')
|
||||
|
||||
function getElectronExec () {
|
||||
switch (process.platform) {
|
||||
case 'darwin':
|
||||
return `out/${OUT_DIR}/Electron.app/Contents/MacOS/Electron`
|
||||
case 'win32':
|
||||
return `out/${OUT_DIR}/electron.exe`
|
||||
case 'linux':
|
||||
return `out/${OUT_DIR}/electron`
|
||||
default:
|
||||
throw new Error('Unknown platform')
|
||||
}
|
||||
}
|
||||
|
||||
function getAbsoluteElectronExec () {
|
||||
return path.resolve(__dirname, '../../..', getElectronExec())
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getElectronExec,
|
||||
getAbsoluteElectronExec,
|
||||
OUT_DIR
|
||||
}
|
|
@ -4,9 +4,10 @@ const fs = require('fs')
|
|||
const { hashElement } = require('folder-hash')
|
||||
const path = require('path')
|
||||
|
||||
const utils = require('./lib/utils')
|
||||
|
||||
const BASE = path.resolve(__dirname, '../..')
|
||||
const NPM_CMD = process.platform === 'win32' ? 'npm.cmd' : 'npm'
|
||||
const OUT_DIR = process.env.ELECTRON_SPEC_OUT_DIR || 'Default'
|
||||
|
||||
const specHashPath = path.resolve(__dirname, '../spec/.hash')
|
||||
|
||||
|
@ -20,7 +21,7 @@ getSpecHash().then(([currentSpecHash, currentSpecInstallHash]) => {
|
|||
if (specChanged || installChanged) {
|
||||
const out = cp.spawnSync(NPM_CMD, ['install'], {
|
||||
env: Object.assign({}, process.env, {
|
||||
npm_config_nodedir: path.resolve(BASE, `out/${OUT_DIR}/gen/node_headers`),
|
||||
npm_config_nodedir: path.resolve(BASE, `out/${utils.OUT_DIR}/gen/node_headers`),
|
||||
npm_config_msvs_version: '2017'
|
||||
}),
|
||||
cwd: path.resolve(__dirname, '../spec')
|
||||
|
@ -35,7 +36,7 @@ getSpecHash().then(([currentSpecHash, currentSpecInstallHash]) => {
|
|||
})
|
||||
}
|
||||
}).then(() => {
|
||||
let exe = path.resolve(BASE, getElectronExec())
|
||||
let exe = path.resolve(BASE, utils.getElectronExec())
|
||||
const args = process.argv.slice(2)
|
||||
if (process.platform === 'linux') {
|
||||
args.unshift(path.resolve(__dirname, 'lib/dbus_mock.py'), exe)
|
||||
|
@ -50,19 +51,6 @@ getSpecHash().then(([currentSpecHash, currentSpecInstallHash]) => {
|
|||
})
|
||||
})
|
||||
|
||||
function getElectronExec () {
|
||||
switch (process.platform) {
|
||||
case 'darwin':
|
||||
return 'out/Default/Electron.app/Contents/MacOS/Electron'
|
||||
case 'win32':
|
||||
return 'out/Default/electron.exe'
|
||||
case 'linux':
|
||||
return 'out/Default/electron'
|
||||
default:
|
||||
throw new Error('Unknown path')
|
||||
}
|
||||
}
|
||||
|
||||
function getSpecHash () {
|
||||
return Promise.all([
|
||||
new Promise((resolve) => {
|
||||
|
|
18
script/start.js
Normal file
18
script/start.js
Normal file
|
@ -0,0 +1,18 @@
|
|||
const cp = require('child_process')
|
||||
|
||||
const utils = require('./lib/utils')
|
||||
|
||||
const electronPath = utils.getAbsoluteElectronExec()
|
||||
|
||||
var child = cp.spawn(electronPath, process.argv.slice(2), { stdio: 'inherit' })
|
||||
child.on('close', (code) => process.exit(code))
|
||||
|
||||
const handleTerminationSignal = (signal) =>
|
||||
process.on(signal, () => {
|
||||
if (!child.killed) {
|
||||
child.kill(signal)
|
||||
}
|
||||
})
|
||||
|
||||
handleTerminationSignal('SIGINT')
|
||||
handleTerminationSignal('SIGTERM')
|
|
@ -13,7 +13,7 @@ ctx.verify_mode = ssl.CERT_NONE
|
|||
|
||||
def check_tls(verbose):
|
||||
process = subprocess.Popen(
|
||||
'node tls.js',
|
||||
'node lib/tls',
|
||||
cwd=os.path.dirname(os.path.realpath(__file__)),
|
||||
shell=True,
|
||||
stdout=subprocess.PIPE,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue