chore: replace Object.assign with object spread syntax (#34739)
This commit is contained in:
parent
ba4893c248
commit
e2c58d164d
8 changed files with 27 additions and 21 deletions
|
@ -18,10 +18,11 @@ if (!OUT_DIR) {
|
|||
throw new Error('No viable out dir: one of Debug, Testing, or Release must exist.');
|
||||
}
|
||||
|
||||
const env = Object.assign({
|
||||
const env = {
|
||||
CHROMIUM_BUILDTOOLS_PATH: path.resolve(SOURCE_ROOT, '..', 'buildtools'),
|
||||
DEPOT_TOOLS_WIN_TOOLCHAIN: '0'
|
||||
}, process.env);
|
||||
DEPOT_TOOLS_WIN_TOOLCHAIN: '0',
|
||||
...process.env
|
||||
};
|
||||
// Users may not have depot_tools in PATH.
|
||||
env.PATH = `${env.PATH}${path.delimiter}${DEPOT_TOOLS}`;
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ const IGNORELIST = new Set([
|
|||
const IS_WINDOWS = process.platform === 'win32';
|
||||
|
||||
function spawnAndCheckExitCode (cmd, args, opts) {
|
||||
opts = Object.assign({ stdio: 'inherit' }, opts);
|
||||
opts = { stdio: 'inherit', ...opts };
|
||||
const { error, status, signal } = childProcess.spawnSync(cmd, args, opts);
|
||||
if (error) {
|
||||
// the subsprocess failed or timed out
|
||||
|
@ -103,7 +103,7 @@ const LINTERS = [{
|
|||
run: (opts, filenames) => {
|
||||
const rcfile = path.join(DEPOT_TOOLS, 'pylintrc');
|
||||
const args = ['--rcfile=' + rcfile, ...filenames];
|
||||
const env = Object.assign({ PYTHONPATH: path.join(ELECTRON_ROOT, 'script') }, process.env);
|
||||
const env = { PYTHONPATH: path.join(ELECTRON_ROOT, 'script'), ...process.env };
|
||||
spawnAndCheckExitCode('pylint-2.7', args, { env });
|
||||
}
|
||||
}, {
|
||||
|
@ -143,10 +143,11 @@ const LINTERS = [{
|
|||
test: filename => filename.endsWith('.gn') || filename.endsWith('.gni'),
|
||||
run: (opts, filenames) => {
|
||||
const allOk = filenames.map(filename => {
|
||||
const env = Object.assign({
|
||||
const env = {
|
||||
CHROMIUM_BUILDTOOLS_PATH: path.resolve(ELECTRON_ROOT, '..', 'buildtools'),
|
||||
DEPOT_TOOLS_WIN_TOOLCHAIN: '0'
|
||||
}, process.env);
|
||||
DEPOT_TOOLS_WIN_TOOLCHAIN: '0',
|
||||
...process.env
|
||||
};
|
||||
// Users may not have depot_tools in PATH.
|
||||
env.PATH = `${env.PATH}${path.delimiter}${DEPOT_TOOLS}`;
|
||||
const args = ['format', filename];
|
||||
|
|
|
@ -20,12 +20,13 @@ const args = require('minimist')(process.argv.slice(2), {
|
|||
async function main () {
|
||||
const outDir = utils.getOutDir({ shouldLog: true });
|
||||
const nodeDir = path.resolve(BASE, 'out', outDir, 'gen', 'node_headers');
|
||||
const env = Object.assign({}, process.env, {
|
||||
const env = {
|
||||
...process.env,
|
||||
npm_config_nodedir: nodeDir,
|
||||
npm_config_msvs_version: '2019',
|
||||
npm_config_arch: process.env.NPM_CONFIG_ARCH,
|
||||
npm_config_yes: 'true'
|
||||
});
|
||||
};
|
||||
|
||||
const clangDir = path.resolve(BASE, 'third_party', 'llvm-build', 'Release+Asserts', 'bin');
|
||||
const cc = path.resolve(clangDir, 'clang');
|
||||
|
|
|
@ -167,7 +167,7 @@ new Promise((resolve, reject) => {
|
|||
const tarballPath = path.join(tempDir, `${rootPackageJson.name}-${rootPackageJson.version}.tgz`);
|
||||
return new Promise((resolve, reject) => {
|
||||
const result = childProcess.spawnSync('npm', ['install', tarballPath, '--force', '--silent'], {
|
||||
env: Object.assign({}, process.env, { electron_config_cache: tempDir }),
|
||||
env: { ...process.env, electron_config_cache: tempDir },
|
||||
cwd: tempDir,
|
||||
stdio: 'inherit'
|
||||
});
|
||||
|
|
|
@ -235,12 +235,13 @@ async function installSpecModules (dir) {
|
|||
const CXXFLAGS = ['-std=c++17', process.env.CXXFLAGS].filter(x => !!x).join(' ');
|
||||
|
||||
const nodeDir = path.resolve(BASE, `out/${utils.getOutDir({ shouldLog: true })}/gen/node_headers`);
|
||||
const env = Object.assign({}, process.env, {
|
||||
const env = {
|
||||
...process.env,
|
||||
CXXFLAGS,
|
||||
npm_config_nodedir: nodeDir,
|
||||
npm_config_msvs_version: '2019',
|
||||
npm_config_yes: 'true'
|
||||
});
|
||||
};
|
||||
if (fs.existsSync(path.resolve(dir, 'node_modules'))) {
|
||||
await fs.remove(path.resolve(dir, 'node_modules'));
|
||||
}
|
||||
|
|
|
@ -1040,7 +1040,7 @@ describe('BrowserWindow module', () => {
|
|||
const boundsUpdate = { width: 200 };
|
||||
w.setBounds(boundsUpdate as any);
|
||||
|
||||
const expectedBounds = Object.assign(fullBounds, boundsUpdate);
|
||||
const expectedBounds = { ...fullBounds, ...boundsUpdate };
|
||||
expectBoundsEqual(w.getBounds(), expectedBounds);
|
||||
});
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ describe('node feature', () => {
|
|||
child.kill();
|
||||
});
|
||||
|
||||
const env = Object.assign({}, process.env, { NODE_OPTIONS: '--v8-options' });
|
||||
const env = { ...process.env, NODE_OPTIONS: '--v8-options' };
|
||||
child = childProcess.spawn(process.execPath, { env });
|
||||
exitPromise = emittedOnce(child, 'exit');
|
||||
|
||||
|
@ -113,7 +113,7 @@ describe('node feature', () => {
|
|||
child.kill();
|
||||
});
|
||||
|
||||
const env = Object.assign({}, process.env, { NODE_OPTIONS: '--use-openssl-ca' });
|
||||
const env = { ...process.env, NODE_OPTIONS: '--use-openssl-ca' };
|
||||
child = childProcess.spawn(process.execPath, ['--enable-logging'], { env });
|
||||
|
||||
let output = '';
|
||||
|
@ -136,9 +136,10 @@ describe('node feature', () => {
|
|||
|
||||
it('does allow --require in non-packaged apps', async () => {
|
||||
const appPath = path.join(fixtures, 'module', 'noop.js');
|
||||
const env = Object.assign({}, process.env, {
|
||||
const env = {
|
||||
...process.env,
|
||||
NODE_OPTIONS: `--require=${path.join(fixtures, 'module', 'fail.js')}`
|
||||
});
|
||||
};
|
||||
// App should exit with code 1.
|
||||
const child = childProcess.spawn(process.execPath, [appPath], { env });
|
||||
const [code] = await emittedOnce(child, 'exit');
|
||||
|
@ -147,10 +148,11 @@ describe('node feature', () => {
|
|||
|
||||
it('does not allow --require in packaged apps', async () => {
|
||||
const appPath = path.join(fixtures, 'module', 'noop.js');
|
||||
const env = Object.assign({}, process.env, {
|
||||
const env = {
|
||||
...process.env,
|
||||
ELECTRON_FORCE_IS_PACKAGED: 'true',
|
||||
NODE_OPTIONS: `--require=${path.join(fixtures, 'module', 'fail.js')}`
|
||||
});
|
||||
};
|
||||
// App should exit with code 0.
|
||||
const child = childProcess.spawn(process.execPath, [appPath], { env });
|
||||
const [code] = await emittedOnce(child, 'exit');
|
||||
|
|
|
@ -63,7 +63,7 @@ describe('shell module', () => {
|
|||
expect(shell.readShortcutLink(tmpShortcut)).to.deep.equal(shortcutOptions);
|
||||
const change = { target: 'D:\\' };
|
||||
expect(shell.writeShortcutLink(tmpShortcut, 'update', change)).to.be.true();
|
||||
expect(shell.readShortcutLink(tmpShortcut)).to.deep.equal(Object.assign(shortcutOptions, change));
|
||||
expect(shell.readShortcutLink(tmpShortcut)).to.deep.equal({ ...shortcutOptions, ...change });
|
||||
});
|
||||
|
||||
it('replaces the shortcut', () => {
|
||||
|
|
Loading…
Reference in a new issue