diff --git a/.github/workflows/pake-cli.yaml b/.github/workflows/pake-cli.yaml index 727514f..e8cb3a8 100644 --- a/.github/workflows/pake-cli.yaml +++ b/.github/workflows/pake-cli.yaml @@ -117,7 +117,7 @@ jobs: - name: Install dependencies run: | - npm install shelljs + npm install execa npm install axios - name: Build with pake-cli diff --git a/bin/helpers/rust.ts b/bin/helpers/rust.ts index e7fd91b..661f8ee 100644 --- a/bin/helpers/rust.ts +++ b/bin/helpers/rust.ts @@ -1,5 +1,5 @@ import chalk from 'chalk'; -import shelljs from 'shelljs'; +import { execaSync } from 'execa'; import { getSpinner } from '@/utils/info'; import { IS_WIN } from '@/utils/platform'; @@ -28,5 +28,10 @@ export async function installRust() { } export function checkRustInstalled() { - return shelljs.exec('rustc --version', { silent: true }).code === 0; + try { + execaSync('rustc', ['--version']); + return true; + } catch { + return false; + } } diff --git a/bin/utils/shell.ts b/bin/utils/shell.ts index d750e82..404c451 100644 --- a/bin/utils/shell.ts +++ b/bin/utils/shell.ts @@ -1,14 +1,14 @@ -import shelljs from 'shelljs'; +import { execa } from 'execa'; import { npmDirectory } from './dir'; -export function shellExec(command: string) { - return new Promise((resolve, reject) => { - shelljs.exec(command, { async: true, silent: false, cwd: npmDirectory }, code => { - if (code === 0) { - resolve(0); - } else { - reject(new Error(`Error occurred while executing command "${command}". Exit code: ${code}`)); - } +export async function shellExec(command: string) { + try { + const { exitCode } = await execa(command, { + cwd: npmDirectory, + stdio: 'inherit' }); - }); + return exitCode; + } catch (error) { + throw new Error(`Error occurred while executing command "${command}". Exit code: ${error.exitCode}`); + } }