diff --git a/common/autoinstallers/lint/change-all.ts b/common/autoinstallers/lint/change-all.ts index 4b3a7fe480..0988ed3c77 100644 --- a/common/autoinstallers/lint/change-all.ts +++ b/common/autoinstallers/lint/change-all.ts @@ -1,7 +1,7 @@ import path from 'path'; import chalk from 'chalk'; import minimist, { ParsedArgs } from 'minimist'; -import { spawnSync, execSync } from 'child_process'; +import { execSync } from 'child_process'; interface RunScriptArgv extends ParsedArgs { message?: string; @@ -31,12 +31,12 @@ function run() { ); message = lastCommitMessage; } else { - const result = spawnSync('sh', ['-c', `echo ${message} | ${commitLintBinPath} --config ${commitLineConfigPath}`], { - stdio: 'inherit' - }); - - if (result.status !== 0) { - process.exit(1); + try { + execSync(`echo ${message} | ${commitLintBinPath} --config ${commitLineConfigPath}`, { + stdio: 'inherit' + }); + } catch (e) { + console.error(`encountered error: ${e}`); } } @@ -47,20 +47,17 @@ function run() { bumpType = 'patch'; } - spawnSync('sh', ['-c', `rush change --bulk --bump-type '${bumpType}' --message '${message}'`], { - stdio: 'inherit', - shell: false + execSync(`rush change --bulk --bump-type '${bumpType}' --message '${message}'`, { + stdio: 'inherit' }); if (!notCommit) { - spawnSync('sh', ['-c', 'git add --all'], { - stdio: 'inherit', - shell: false + execSync('git add --all', { + stdio: 'inherit' }); - spawnSync('sh', ['-c', `git commit -m 'docs: update changlog of rush'`], { - stdio: 'inherit', - shell: false + execSync(`git commit -m 'docs: update changlog of rush'`, { + stdio: 'inherit' }); } } diff --git a/common/autoinstallers/lint/commit-lint.js b/common/autoinstallers/lint/commit-lint.js index 75cdd71752..2084d0762c 100644 --- a/common/autoinstallers/lint/commit-lint.js +++ b/common/autoinstallers/lint/commit-lint.js @@ -1,24 +1,23 @@ -const path = require("path"); -const fs = require("fs"); -const child_process = require("child_process"); +const path = require('path'); +const fs = require('fs'); +const child_process = require('child_process'); -const gitPath = path.resolve(__dirname, "../../../.git"); -const configPath = path.resolve(__dirname, "./commitlint.config.js"); -const commitlintBinPath = path.resolve(__dirname, "./node_modules/.bin/commitlint"); +const gitPath = path.resolve(__dirname, '../../../.git'); +const configPath = path.resolve(__dirname, './commitlint.config.js'); +const commitlintBinPath = path.resolve(__dirname, './node_modules/.bin/commitlint'); if (!fs.existsSync(gitPath)) { - console.error("no valid .git path"); + console.error('no valid .git path'); process.exit(1); } -const result = child_process.spawnSync( - "sh", - ["-c", `${commitlintBinPath} --config ${configPath} --cwd ${path.dirname(gitPath)} --edit`], - { - stdio: "inherit", - }, -); +try { + child_process.execSync(`${commitlintBinPath} --config ${configPath} --cwd ${path.dirname(gitPath)} --edit`, { + stdio: 'inherit', + windowsHide: true + }); -if (result.status !== 0) { +} catch (e) { + console.error(`lint error: ${e}`); process.exit(1); } diff --git a/common/autoinstallers/lint/prettier.ts b/common/autoinstallers/lint/prettier.ts index 4748c05f84..a226af6d67 100644 --- a/common/autoinstallers/lint/prettier.ts +++ b/common/autoinstallers/lint/prettier.ts @@ -1,6 +1,6 @@ -import minimist, { ParsedArgs } from "minimist"; -import { spawnSync } from "child_process"; -import { RushConfiguration } from "@microsoft/rush-lib"; +import minimist, { ParsedArgs } from 'minimist'; +import { execSync } from 'child_process'; +import { RushConfiguration } from '@microsoft/rush-lib'; interface PrettierScriptArgv extends ParsedArgs { dir?: string; @@ -12,12 +12,12 @@ function run() { const rushConfiguration = RushConfiguration.loadFromDefaultLocation({ startingFolder: cwd }); const argv: PrettierScriptArgv = minimist(process.argv.slice(2)); - const configFilePath = rushConfiguration.rushJsonFolder + "/.prettierrc.js"; - const ignoreFilePath = rushConfiguration.rushJsonFolder + "/.prettierignore"; + const configFilePath = rushConfiguration.rushJsonFolder + '/.prettierrc.js'; + const ignoreFilePath = rushConfiguration.rushJsonFolder + '/.prettierignore'; - let ext = "{ts,tsx,less}"; + let ext = '{ts,tsx,less}'; if (argv.ext) { - const length = argv.ext.split(",").length; + const length = argv.ext.split(',').length; ext = length === 1 ? `${argv.ext}` : `{${argv.ext}}`; } @@ -28,17 +28,9 @@ function run() { console.log(patterns); - spawnSync( - "sh", - [ - "-c", - `prettier --config ${configFilePath} --ignore-path ${ignoreFilePath} --write ${patterns}`, - ], - { - shell: false, - stdio: [0, 1, 2], - }, - ); + execSync(`prettier --config ${configFilePath} --ignore-path ${ignoreFilePath} --write ${patterns}`, { + stdio: [0, 1, 2] + }); } run(); diff --git a/common/autoinstallers/run-script/run.ts b/common/autoinstallers/run-script/run.ts index 7f311c1558..42ec7dd3fe 100644 --- a/common/autoinstallers/run-script/run.ts +++ b/common/autoinstallers/run-script/run.ts @@ -1,6 +1,6 @@ -import minimist, { ParsedArgs } from "minimist"; -import { RushConfiguration } from "@microsoft/rush-lib"; -import { spawnSync } from "child_process"; +import minimist, { ParsedArgs } from 'minimist'; +import { RushConfiguration } from '@microsoft/rush-lib'; +import { execSync } from 'child_process'; interface RunScriptArgv extends ParsedArgs { project?: string; @@ -10,19 +10,19 @@ interface RunScriptArgv extends ParsedArgs { function run() { const argv: RunScriptArgv = minimist(process.argv.slice(2)); const projects = RushConfiguration.loadFromDefaultLocation({ - startingFolder: process.cwd(), + startingFolder: process.cwd() }); const targetProject = projects.findProjectByShorthandName(argv.project!); if (targetProject) { - const result = spawnSync("sh", ["-c", `rushx ${argv.script}`], { - cwd: targetProject?.projectFolder, - shell: false, - stdio: [0, 1, 2], - }); - if (result.status !== 0) { - process.exit(result.status); + try { + execSync(`rushx ${argv.script}`, { + cwd: targetProject?.projectFolder, + stdio: [0, 1, 2] + }); + } catch (e) { + console.error(`Encountered error: ${e}`); } } } diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index b335026ac5..6acbd0b6e3 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -375,6 +375,7 @@ importers: '@visactor/vutils': ~0.18.6 '@visactor/vutils-extension': workspace:1.11.0 canvas: 2.11.2 + cross-env: ^7.0.3 d3-array: ^1.2.4 d3-dsv: ^3.0.1 d3-geo: ^1.12.1 @@ -434,6 +435,7 @@ importers: '@types/node': 20.12.10 '@types/offscreencanvas': 2019.6.4 canvas: 2.11.2 + cross-env: 7.0.3 d3-array: 1.2.4 d3-dsv: 3.0.1 d3-geo: 1.12.1 diff --git a/packages/vchart/package.json b/packages/vchart/package.json index 3d4befae48..dc75ebced3 100644 --- a/packages/vchart/package.json +++ b/packages/vchart/package.json @@ -24,8 +24,8 @@ "build:cjs": "bundle --clean -f cjs --ignorePostTasks --ignoreUmdEntries", "build:es": "bundle --clean -f es --ignorePostTasks", "analyze": "npm run analyze-full && npm run analyze-line && npm run analyze-simple", - "analyze-full": "BUNDLE_ANALYZE='full' bundle -f umd ", - "analyze-simple": "BUNDLE_ANALYZE='simple' bundle -f umd", + "analyze-full": "cross-env BUNDLE_ANALYZE='full' bundle -f umd ", + "analyze-simple": "cross-env BUNDLE_ANALYZE='simple' bundle -f umd", "dev": "bundle --clean -f es -w", "compile": "tsc --noEmit", "start": "ts-node __tests__/runtime/browser/scripts/initVite.ts && vite serve __tests__/runtime/browser", @@ -39,7 +39,7 @@ "test": "jest", "test-cov": "jest -w 16 --coverage", "test-live": "npm run test-watch __tests__/unit", - "test-watch": "DEBUG_MODE=1 jest --watch", + "test-watch": "cross-env DEBUG_MODE=1 jest --watch", "ci": "ts-node --transpileOnly --skipProject ./scripts/trigger-test.ts", "size": "size-limit" }, @@ -112,7 +112,8 @@ "canvas": "2.11.2", "size-limit": "9.0.0", "@size-limit/file": "9.0.0", - "rimraf": "3.0.2" + "rimraf": "3.0.2", + "cross-env": "^7.0.3" }, "dependencies": { "@visactor/vutils": "~0.18.6",