summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLeo Goetz <dev@leogtz.de>2026-05-21 08:33:11 +0200
committerLeo Goetz <dev@leogtz.de>2026-05-21 08:33:11 +0200
commit67ebcd712c79ce179f037b71bf78c0bfab1e2f9c (patch)
tree7384d885fb8e1a3b6d968b6791786116e807c8ca /src
parent3535855bc0df3460b7abe0cb2860a677fa50a435 (diff)
refactor: replace promiseExec callback with promise
Diffstat (limited to 'src')
-rw-r--r--src/actions/checkDependencies.ts36
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 });
});
});
}