mirror of
https://github.com/youzan/vant.git
synced 2026-05-06 01:00:26 +08:00
refactor(cli): remove execa dependency (#12205)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import fse from 'fs-extra';
|
||||
import { execa } from 'execa';
|
||||
import { execSync } from 'child_process';
|
||||
import { join, relative } from 'node:path';
|
||||
import { clean } from './clean.js';
|
||||
import { CSS_LANG } from '../common/css.js';
|
||||
@@ -104,9 +104,8 @@ async function buildTypeDeclarations() {
|
||||
const tsConfig = join(process.cwd(), 'tsconfig.declaration.json');
|
||||
|
||||
if (existsSync(tsConfig)) {
|
||||
await execa('tsc', ['-p', tsConfig], {
|
||||
stdout: 'inherit',
|
||||
stderr: 'inherit',
|
||||
execSync(`tsc -p ${tsConfig}`, {
|
||||
stdio: 'inherit',
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { execa } from 'execa';
|
||||
import { exec } from 'child_process';
|
||||
import { consola, createSpinner } from '../common/logger.js';
|
||||
import { SCRIPT_EXTS } from '../common/constant.js';
|
||||
|
||||
@@ -8,40 +8,33 @@ type RunCommandMessages = {
|
||||
failed: string;
|
||||
};
|
||||
|
||||
function runCommand(
|
||||
cmd: string,
|
||||
options: string[],
|
||||
messages: RunCommandMessages,
|
||||
) {
|
||||
function runCommand(cmd: string, messages: RunCommandMessages) {
|
||||
const spinner = createSpinner(messages.start).start();
|
||||
|
||||
return new Promise((resolve) => {
|
||||
execa(cmd, options, {
|
||||
preferLocal: true,
|
||||
env: { FORCE_COLOR: 'true' },
|
||||
})
|
||||
.then(() => {
|
||||
const options = {
|
||||
env: Object.assign({}, process.env, { FORCE_COLOR: 'true' }),
|
||||
};
|
||||
|
||||
exec(cmd, options, (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
consola.error(stderr || stdout);
|
||||
spinner.error({ text: messages.failed });
|
||||
resolve(false);
|
||||
} else {
|
||||
spinner.success({ text: messages.succeed });
|
||||
resolve(true);
|
||||
})
|
||||
.catch((err: any) => {
|
||||
spinner.error({ text: messages.failed });
|
||||
consola.error(err.stderr || err.stdout);
|
||||
resolve(false);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function eslint() {
|
||||
return runCommand(
|
||||
'eslint',
|
||||
['./src', '--fix', '--ext', SCRIPT_EXTS.join(',')],
|
||||
{
|
||||
start: 'Running eslint...',
|
||||
succeed: 'ESLint Passed.',
|
||||
failed: 'ESLint failed!',
|
||||
},
|
||||
);
|
||||
return runCommand(`eslint ./src --fix --ext ${SCRIPT_EXTS.join(',')}`, {
|
||||
start: 'Running eslint...',
|
||||
succeed: 'ESLint Passed.',
|
||||
failed: 'ESLint failed!',
|
||||
});
|
||||
}
|
||||
|
||||
export async function lint() {
|
||||
|
||||
Reference in New Issue
Block a user