refactor: use @malept/cross-spawn-promise instead of cross-spawn-promise (#1496)

This commit is contained in:
Mark Lee 2020-02-16 15:59:50 -08:00 коммит произвёл GitHub
Родитель fe800f640d
Коммит 62998e5c35
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
16 изменённых файлов: 35 добавлений и 37 удалений

Просмотреть файл

@ -49,13 +49,13 @@
}, },
"dependencies": { "dependencies": {
"@electron/get": "^1.7.6", "@electron/get": "^1.7.6",
"@malept/cross-spawn-promise": "^1.0.0",
"@octokit/rest": "^16.43.1", "@octokit/rest": "^16.43.1",
"@types/which": "^1.3.2", "@types/which": "^1.3.2",
"aws-sdk": "^2.472.0", "aws-sdk": "^2.472.0",
"colors": "^1.4.0", "colors": "^1.4.0",
"commander": "^4.1.1", "commander": "^4.1.1",
"cross-spawn": "^7.0.1", "cross-spawn": "^7.0.1",
"cross-spawn-promise": "^0.10.1",
"cross-zip": "^3.0.0", "cross-zip": "^3.0.0",
"debug": "^4.1.0", "debug": "^4.1.0",
"electron-osx-sign": "^0.4.15", "electron-osx-sign": "^0.4.15",

Просмотреть файл

@ -11,9 +11,9 @@
"electron-forge-vscode-win": "script/vscode.cmd" "electron-forge-vscode-win": "script/vscode.cmd"
}, },
"devDependencies": { "devDependencies": {
"@malept/cross-spawn-promise": "^1.0.0",
"chai": "4.2.0", "chai": "4.2.0",
"chai-as-promised": "^7.0.0", "chai-as-promised": "^7.0.0",
"cross-spawn-promise": "^0.10.1",
"mocha": "^7.0.1" "mocha": "^7.0.1"
}, },
"dependencies": { "dependencies": {

Просмотреть файл

@ -1,7 +1,7 @@
import chai, { expect } from 'chai'; import chai, { expect } from 'chai';
import chaiAsPromised from 'chai-as-promised'; import chaiAsPromised from 'chai-as-promised';
import path from 'path'; import path from 'path';
import spawnPromise from 'cross-spawn-promise'; import { spawn } from '@malept/cross-spawn-promise';
chai.use(chaiAsPromised); chai.use(chaiAsPromised);
@ -10,12 +10,12 @@ function tsNodePath() {
return process.platform === 'win32' ? `${tsNode}.cmd` : tsNode; return process.platform === 'win32' ? `${tsNode}.cmd` : tsNode;
} }
function runForgeCLI(...extraArgs: string[]): Promise<Uint8Array> { function runForgeCLI(...extraArgs: string[]): Promise<string> {
const args = [ const args = [
path.resolve(__dirname, '../src/electron-forge.ts'), path.resolve(__dirname, '../src/electron-forge.ts'),
...extraArgs, ...extraArgs,
]; ];
return spawnPromise(tsNodePath(), args); return spawn(tsNodePath(), args);
} }
describe('cli', () => { describe('cli', () => {
@ -26,7 +26,7 @@ describe('cli', () => {
it('should fail on unknown subcommands', async () => { it('should fail on unknown subcommands', async () => {
const error = await expect(runForgeCLI('nonexistent')).to.eventually.be.rejected; const error = await expect(runForgeCLI('nonexistent')).to.eventually.be.rejected;
expect(error.exitStatus).to.equal(1); expect(error.code).to.equal(1);
expect(error.stderr.toString()).to.match(/Unknown command "nonexistent"/); expect(error.stderr).to.match(/Unknown command "nonexistent"/);
}); });
}); });

Просмотреть файл

@ -43,8 +43,8 @@
"@electron-forge/template-typescript-webpack": "6.0.0-beta.49", "@electron-forge/template-typescript-webpack": "6.0.0-beta.49",
"@electron-forge/template-webpack": "6.0.0-beta.49", "@electron-forge/template-webpack": "6.0.0-beta.49",
"@electron/get": "^1.7.6", "@electron/get": "^1.7.6",
"@malept/cross-spawn-promise": "^1.0.0",
"colors": "^1.4.0", "colors": "^1.4.0",
"cross-spawn-promise": "^0.10.1",
"debug": "^4.1.0", "debug": "^4.1.0",
"electron-packager": "^14.2.0", "electron-packager": "^14.2.0",
"electron-rebuild": "^1.8.6", "electron-rebuild": "^1.8.6",

Просмотреть файл

@ -1,4 +1,4 @@
import spawnPromise from 'cross-spawn-promise'; import { spawn } from '@malept/cross-spawn-promise';
import logSymbols from 'log-symbols'; import logSymbols from 'log-symbols';
import yarnOrNpm from 'yarn-or-npm'; import yarnOrNpm from 'yarn-or-npm';
@ -20,6 +20,6 @@ const safeYarnOrNpm = () => {
export default safeYarnOrNpm; export default safeYarnOrNpm;
// eslint-disable-next-line max-len // eslint-disable-next-line max-len
export const yarnOrNpmSpawn = (args?: string[], opts?: any) => spawnPromise(safeYarnOrNpm(), args, opts); export const yarnOrNpmSpawn = (args?: string[], opts?: any) => spawn(safeYarnOrNpm(), args, opts);
export const hasYarn = () => safeYarnOrNpm() === 'yarn'; export const hasYarn = () => safeYarnOrNpm() === 'yarn';

Просмотреть файл

@ -15,7 +15,7 @@
}, },
"dependencies": { "dependencies": {
"@electron-forge/installer-darwin": "6.0.0-beta.49", "@electron-forge/installer-darwin": "6.0.0-beta.49",
"cross-spawn-promise": "^0.10.1", "@malept/cross-spawn-promise": "^1.0.0",
"debug": "^4.1.0", "debug": "^4.1.0",
"fs-extra": "^8.1.0" "fs-extra": "^8.1.0"
} }

Просмотреть файл

@ -1,6 +1,6 @@
import InstallerDarwin, { InstallerOptions } from '@electron-forge/installer-darwin'; import InstallerDarwin, { InstallerOptions } from '@electron-forge/installer-darwin';
import spawnPromise from 'cross-spawn-promise'; import { spawn } from '@malept/cross-spawn-promise';
import fs from 'fs-extra'; import fs from 'fs-extra';
import path from 'path'; import path from 'path';
@ -31,7 +31,7 @@ export default class InstallerDMG extends InstallerDarwin {
await this.moveApp(appPath, targetApplicationPath, installSpinner, true); await this.moveApp(appPath, targetApplicationPath, installSpinner, true);
await spawnPromise('open', ['-R', targetApplicationPath], { detached: true } as any); await spawn('open', ['-R', targetApplicationPath], { detached: true } as any);
} finally { } finally {
await unmountImage(targetMount); await unmountImage(targetMount);
} }

Просмотреть файл

@ -1,4 +1,4 @@
import spawnPromise from 'cross-spawn-promise'; import { spawn } from '@malept/cross-spawn-promise';
import debug from 'debug'; import debug from 'debug';
const d = debug('electron-forge:hdiutil'); const d = debug('electron-forge:hdiutil');
@ -9,7 +9,7 @@ export interface Mount {
} }
export const getMountedImages = async (): Promise<Mount[]> => { export const getMountedImages = async (): Promise<Mount[]> => {
const output = await spawnPromise('hdiutil', ['info']); const output = await spawn('hdiutil', ['info']);
const mounts = output.toString().split(/====\n/g); const mounts = output.toString().split(/====\n/g);
mounts.shift(); mounts.shift();
@ -31,7 +31,7 @@ export const getMountedImages = async (): Promise<Mount[]> => {
export const mountImage = async (filePath: string): Promise<Mount> => { export const mountImage = async (filePath: string): Promise<Mount> => {
d('mounting image:', filePath); d('mounting image:', filePath);
const output = await spawnPromise('hdiutil', ['attach', '-noautoopen', '-nobrowse', '-noverify', filePath]); const output = await spawn('hdiutil', ['attach', '-noautoopen', '-nobrowse', '-noverify', filePath]);
const mountPath = /\/Volumes\/(.+)\n/g.exec(output.toString())![1]; const mountPath = /\/Volumes\/(.+)\n/g.exec(output.toString())![1];
d('mounted at:', mountPath); d('mounted at:', mountPath);
@ -43,5 +43,5 @@ export const mountImage = async (filePath: string): Promise<Mount> => {
export const unmountImage = async (mount: Mount) => { export const unmountImage = async (mount: Mount) => {
d('unmounting current mount:', mount); d('unmounting current mount:', mount);
await spawnPromise('hdiutil', ['unmount', '-force', `/Volumes/${mount.mountPath}`]); await spawn('hdiutil', ['unmount', '-force', `/Volumes/${mount.mountPath}`]);
}; };

Просмотреть файл

@ -15,7 +15,7 @@
}, },
"dependencies": { "dependencies": {
"@electron-forge/installer-darwin": "6.0.0-beta.49", "@electron-forge/installer-darwin": "6.0.0-beta.49",
"cross-spawn-promise": "^0.10.1", "@malept/cross-spawn-promise": "^1.0.0",
"fs-extra": "^8.1.0" "fs-extra": "^8.1.0"
} }
} }

Просмотреть файл

@ -1,6 +1,6 @@
import InstallerDarwin, { InstallerOptions } from '@electron-forge/installer-darwin'; import InstallerDarwin, { InstallerOptions } from '@electron-forge/installer-darwin';
import spawnPromise from 'cross-spawn-promise'; import { spawn } from '@malept/cross-spawn-promise';
import fs from 'fs-extra'; import fs from 'fs-extra';
import path from 'path'; import path from 'path';
@ -11,7 +11,7 @@ export default class InstallerZip extends InstallerDarwin {
filePath, filePath,
installSpinner, installSpinner,
}: InstallerOptions) { }: InstallerOptions) {
await spawnPromise('unzip', ['-q', '-o', path.basename(filePath)], { await spawn('unzip', ['-q', '-o', path.basename(filePath)], {
cwd: path.dirname(filePath), cwd: path.dirname(filePath),
} as any); } as any);
@ -23,6 +23,6 @@ export default class InstallerZip extends InstallerDarwin {
await this.moveApp(appPath, targetApplicationPath, installSpinner); await this.moveApp(appPath, targetApplicationPath, installSpinner);
await spawnPromise('open', ['-R', targetApplicationPath], { detached: true } as any); await spawn('open', ['-R', targetApplicationPath], { detached: true } as any);
} }
} }

Просмотреть файл

@ -22,7 +22,6 @@
"@electron-forge/plugin-base": "6.0.0-beta.49", "@electron-forge/plugin-base": "6.0.0-beta.49",
"@electron-forge/shared-types": "6.0.0-beta.49", "@electron-forge/shared-types": "6.0.0-beta.49",
"@electron-forge/web-multi-logger": "6.0.0-beta.49", "@electron-forge/web-multi-logger": "6.0.0-beta.49",
"cross-spawn-promise": "^0.10.1",
"debug": "^4.1.0", "debug": "^4.1.0",
"express": "^4.17.1", "express": "^4.17.1",
"fs-extra": "^8.1.0", "fs-extra": "^8.1.0",

Просмотреть файл

@ -23,7 +23,6 @@
"devDependencies": { "devDependencies": {
"@electron-forge/test-utils": "6.0.0-beta.49", "@electron-forge/test-utils": "6.0.0-beta.49",
"chai": "4.2.0", "chai": "4.2.0",
"cross-spawn-promise": "^0.10.1",
"proxyquire": "^2.1.3", "proxyquire": "^2.1.3",
"sinon": "^8.1.0" "sinon": "^8.1.0"
} }

Просмотреть файл

@ -8,8 +8,8 @@
"main": "dist/index.js", "main": "dist/index.js",
"typings": "dist/index.d.ts", "typings": "dist/index.d.ts",
"dependencies": { "dependencies": {
"@malept/cross-spawn-promise": "^1.0.0",
"chai": "4.2.0", "chai": "4.2.0",
"cross-spawn-promise": "^0.10.1",
"fs-extra": "^8.1.0" "fs-extra": "^8.1.0"
}, },
"engines": { "engines": {

Просмотреть файл

@ -2,10 +2,10 @@ import { expect } from 'chai';
import fs from 'fs-extra'; import fs from 'fs-extra';
import os from 'os'; import os from 'os';
import path from 'path'; import path from 'path';
import spawnPromise from 'cross-spawn-promise'; import { spawn } from '@malept/cross-spawn-promise';
async function runNPM(dir: string, ...args: string[]) { async function runNPM(dir: string, ...args: string[]) {
await (spawnPromise as Function)('npm', args, { cwd: dir }); await spawn('npm', args, { cwd: dir });
} }
async function runNPMInstall(dir: string, ...args: string[]) { async function runNPMInstall(dir: string, ...args: string[]) {

Просмотреть файл

@ -2,7 +2,7 @@ require('colors');
const childProcess = require('child_process'); const childProcess = require('child_process');
const fs = require('fs-extra'); const fs = require('fs-extra');
const path = require('path'); const path = require('path');
const spawnPromise = require('cross-spawn-promise'); const { spawn } = require('@malept/cross-spawn-promise');
const Listr = require('listr'); const Listr = require('listr');
require('ts-node').register(); require('ts-node').register();
@ -22,7 +22,7 @@ const prepare = new Listr([
}, },
{ {
title: 'Building all packages', title: 'Building all packages',
task: () => spawnPromise('bolt', ['build'], { task: () => spawn('bolt', ['build'], {
cwd: BASE_DIR, cwd: BASE_DIR,
}), }),
}, },
@ -56,7 +56,7 @@ const publisher = new Listr([
title: `Publishing: ${`${name}@${version}`.cyan} (beta=${isBeta ? 'true'.green : 'false'.red})`, title: `Publishing: ${`${name}@${version}`.cyan} (beta=${isBeta ? 'true'.green : 'false'.red})`,
task: async () => { task: async () => {
try { try {
await spawnPromise('npm', ['publish', '--access=public', ...(isBeta ? ['--tag=beta'] : []), `--otp=${ctx.otp}`], { await spawn('npm', ['publish', '--access=public', ...(isBeta ? ['--tag=beta'] : []), `--otp=${ctx.otp}`], {
cwd: dir, cwd: dir,
}); });
} catch (err) { } catch (err) {

Просмотреть файл

@ -885,6 +885,13 @@
resolved "https://registry.yarnpkg.com/@istanbuljs/schema/-/schema-0.1.2.tgz#26520bf09abe4a5644cd5414e37125a8954241dd" resolved "https://registry.yarnpkg.com/@istanbuljs/schema/-/schema-0.1.2.tgz#26520bf09abe4a5644cd5414e37125a8954241dd"
integrity sha512-tsAQNx32a8CoFhjhijUIhI4kccIAgmGhy8LZMZgGfmXcpMbPRUqn5LWmgRttILi6yeGmBJd2xsPkFMs0PzgPCw== integrity sha512-tsAQNx32a8CoFhjhijUIhI4kccIAgmGhy8LZMZgGfmXcpMbPRUqn5LWmgRttILi6yeGmBJd2xsPkFMs0PzgPCw==
"@malept/cross-spawn-promise@^1.0.0":
version "1.0.0"
resolved "https://registry.yarnpkg.com/@malept/cross-spawn-promise/-/cross-spawn-promise-1.0.0.tgz#dcd07bc45e818d945d400247a297fc1d95e7766c"
integrity sha512-wE6Y5vqqBE0jATZT1oev3twD1beEcBIDwbrZVt9mekFEv3H/REyjdHCr0qulozZsp6DUya3ituJVnC4YacHO9w==
dependencies:
cross-spawn "^7.0.1"
"@malept/electron-installer-flatpak@^0.11.0": "@malept/electron-installer-flatpak@^0.11.0":
version "0.11.1" version "0.11.1"
resolved "https://registry.yarnpkg.com/@malept/electron-installer-flatpak/-/electron-installer-flatpak-0.11.1.tgz#67b707c2d795f9181b437cc936d75404026b268d" resolved "https://registry.yarnpkg.com/@malept/electron-installer-flatpak/-/electron-installer-flatpak-0.11.1.tgz#67b707c2d795f9181b437cc936d75404026b268d"
@ -2962,14 +2969,7 @@ cross-env@^7.0.0:
dependencies: dependencies:
cross-spawn "^7.0.1" cross-spawn "^7.0.1"
cross-spawn-promise@^0.10.1: cross-spawn@^5.0.1:
version "0.10.1"
resolved "https://registry.yarnpkg.com/cross-spawn-promise/-/cross-spawn-promise-0.10.1.tgz#db9cb4c50c60b72a15be049b78122ce382d87b10"
integrity sha1-25y0xQxgtyoVvgSbeBIs44LYexA=
dependencies:
cross-spawn "^5.1.0"
cross-spawn@^5.0.1, cross-spawn@^5.1.0:
version "5.1.0" version "5.1.0"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-5.1.0.tgz#e8bd0efee58fcff6f8f94510a0a554bbfa235449" resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-5.1.0.tgz#e8bd0efee58fcff6f8f94510a0a554bbfa235449"
integrity sha1-6L0O/uWPz/b4+UUQoKVUu/ojVEk= integrity sha1-6L0O/uWPz/b4+UUQoKVUu/ojVEk=