✨ replace shelljs to execa
This commit is contained in:
2
.github/workflows/pake-cli.yaml
vendored
2
.github/workflows/pake-cli.yaml
vendored
@@ -117,7 +117,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
npm install shelljs
|
npm install execa
|
||||||
npm install axios
|
npm install axios
|
||||||
|
|
||||||
- name: Build with pake-cli
|
- name: Build with pake-cli
|
||||||
|
|||||||
9
bin/helpers/rust.ts
vendored
9
bin/helpers/rust.ts
vendored
@@ -1,5 +1,5 @@
|
|||||||
import chalk from 'chalk';
|
import chalk from 'chalk';
|
||||||
import shelljs from 'shelljs';
|
import { execaSync } from 'execa';
|
||||||
|
|
||||||
import { getSpinner } from '@/utils/info';
|
import { getSpinner } from '@/utils/info';
|
||||||
import { IS_WIN } from '@/utils/platform';
|
import { IS_WIN } from '@/utils/platform';
|
||||||
@@ -28,5 +28,10 @@ export async function installRust() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function checkRustInstalled() {
|
export function checkRustInstalled() {
|
||||||
return shelljs.exec('rustc --version', { silent: true }).code === 0;
|
try {
|
||||||
|
execaSync('rustc', ['--version']);
|
||||||
|
return true;
|
||||||
|
} catch {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
20
bin/utils/shell.ts
vendored
20
bin/utils/shell.ts
vendored
@@ -1,14 +1,14 @@
|
|||||||
import shelljs from 'shelljs';
|
import { execa } from 'execa';
|
||||||
import { npmDirectory } from './dir';
|
import { npmDirectory } from './dir';
|
||||||
|
|
||||||
export function shellExec(command: string) {
|
export async function shellExec(command: string) {
|
||||||
return new Promise<number>((resolve, reject) => {
|
try {
|
||||||
shelljs.exec(command, { async: true, silent: false, cwd: npmDirectory }, code => {
|
const { exitCode } = await execa(command, {
|
||||||
if (code === 0) {
|
cwd: npmDirectory,
|
||||||
resolve(0);
|
stdio: 'inherit'
|
||||||
} else {
|
|
||||||
reject(new Error(`Error occurred while executing command "${command}". Exit code: ${code}`));
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
});
|
return exitCode;
|
||||||
|
} catch (error) {
|
||||||
|
throw new Error(`Error occurred while executing command "${command}". Exit code: ${error.exitCode}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user