diff options
Diffstat (limited to 'src/actions')
| -rw-r--r-- | src/actions/checkDependencies.ts | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/src/actions/checkDependencies.ts b/src/actions/checkDependencies.ts index ab0f182..c248903 100644 --- a/src/actions/checkDependencies.ts +++ b/src/actions/checkDependencies.ts @@ -2,7 +2,7 @@ import fs from "fs/promises"; import ora, { type Ora } from "ora"; import type { Config, Project } from "../types.js"; import { getConfig } from "../utils/config.js"; -import { exec } from "child_process"; +import { exec, type ExecException } from "child_process"; export async function checkDependencies() { const spinner = ora("Getting all Project Data").start(); @@ -48,31 +48,31 @@ async function getAuditPromise( await pullLatest(path, spinner); spinner.text = "getting audit"; - promiseExec( - `cd "${path}" && npm audit --json`, - (_: any, stdout: string) => { - let output = JSON.parse(stdout); - let project: Project = { projectName: dirname, ...output }; - if (project.error) { - reject( - `${dirname} could not be audited, maybe package lock is corrupted`, - ); - } - resolve(project); - }, - ); + + let { stdout } = await promiseExec(`cd "${path}" && npm audit --json`); + + let output = JSON.parse(stdout); + let project: Project = { projectName: dirname, ...output }; + if (project.error) { + reject( + `${dirname} could not be audited, maybe package lock is corrupted`, + ); + } + resolve(project); }); } async function pullLatest(path: string, spinner: Ora) { spinner.text = "pulling latest"; - await promiseExec(`cd "${path}" && git pull `, () => {}); + await promiseExec(`cd "${path}" && git pull`); } -function promiseExec<T>(cmd: string, callback: any): Promise<T> { +function promiseExec( + cmd: string, +): Promise<{ error: ExecException | null; stdout: string; stderr: string }> { return new Promise((resolve, _) => { - exec(cmd, (err, stdout, stderr) => { - resolve(callback(err, stdout, stderr)); + exec(cmd, (error, stdout, stderr) => { + resolve({ error, stdout, stderr }); }); }); } |
