cli create: fix installing deps spinner

This commit is contained in:
dswbx
2025-02-14 14:08:15 +01:00
parent 425465becd
commit b412da836c
3 changed files with 26 additions and 6 deletions

View File

@@ -1,4 +1,4 @@
import { execSync } from "node:child_process";
import { execSync, exec as nodeExec } from "node:child_process";
import { readFile } from "node:fs/promises";
import path from "node:path";
import url from "node:url";
@@ -51,3 +51,23 @@ export function exec(command: string, opts?: { silent?: boolean; env?: Record<st
}
return output.toString();
}
export function execAsync(
command: string,
opts?: { silent?: boolean; env?: Record<string, string> }
) {
return new Promise((resolve, reject) => {
nodeExec(
command,
{
env: { ...process.env, ...opts?.env }
},
(err, stdout, stderr) => {
if (err) {
return reject(err);
}
resolve(stdout);
}
);
});
}