summaryrefslogtreecommitdiff
path: root/src/actions/checkDependencies.ts
diff options
context:
space:
mode:
authorLeo Goetz <dev@leogtz.de>2026-05-21 08:34:34 +0200
committerLeo Goetz <dev@leogtz.de>2026-05-21 08:34:34 +0200
commit070a5ecace9942490cd777e3c1decd1b846a877f (patch)
tree3e29e5e4db4e78258e853ac662fe773e3d218e7f /src/actions/checkDependencies.ts
parent67ebcd712c79ce179f037b71bf78c0bfab1e2f9c (diff)
refactor: removed new promise anti pattern from getAuditPromise
Diffstat (limited to 'src/actions/checkDependencies.ts')
-rw-r--r--src/actions/checkDependencies.ts25
1 files changed, 12 insertions, 13 deletions
diff --git a/src/actions/checkDependencies.ts b/src/actions/checkDependencies.ts
index c248903..4234bf9 100644
--- a/src/actions/checkDependencies.ts
+++ b/src/actions/checkDependencies.ts
@@ -44,22 +44,21 @@ async function getAuditPromise(
dirname: string,
spinner: Ora,
): Promise<Project> {
- return new Promise(async (resolve, reject) => {
- await pullLatest(path, spinner);
+ await pullLatest(path, spinner);
- spinner.text = "getting audit";
+ spinner.text = "getting audit";
- let { stdout } = await promiseExec(`cd "${path}" && npm audit --json`);
+ 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);
- });
+ let output = JSON.parse(stdout);
+ let project: Project = { projectName: dirname, ...output };
+ if (project.error) {
+ throw new Error(
+ `${dirname} could not be audited, maybe package lock is corrupted`,
+ );
+ }
+
+ return project;
}
async function pullLatest(path: string, spinner: Ora) {