Skip to content

Commit 6df7f05

Browse files
committed
refactor: use same child process abstraction for CLI output
1 parent 43e819a commit 6df7f05

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

index.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,14 @@ workingDirectory = path.isAbsolute(workingDirectory)
5454
? workingDirectory
5555
: path.join(process.cwd(), workingDirectory);
5656

57+
function cli(cmd: string) {
58+
console.log(`cli: ${cmd}`);
59+
return cp.execSync(cmd).toString().trim();
60+
}
61+
5762
function getEsyCLIVersion() {
5863
const cmd = "esy --version";
59-
return cp.execSync(cmd).toString().trim();
64+
return cli(cmd);
6065
}
6166

6267
function getEsyStoreVersion() {
@@ -106,7 +111,7 @@ function getCompilerVersion(sandbox?: string) {
106111
const ocamlcVersionCmd = sandbox
107112
? `esy ${sandbox} ocamlc --version`
108113
: "esy ocamlc --version";
109-
return cp.execSync(ocamlcVersionCmd).toString();
114+
return cli(ocamlcVersionCmd);
110115
}
111116

112117
async function run(name: string, command: string, args: string[]) {
@@ -468,17 +473,13 @@ async function bundleNPMArtifacts() {
468473
mainPackageJson.esy.release &&
469474
mainPackageJson.esy.release.rewritePrefix;
470475

471-
function exec(cmd: string) {
472-
console.log(`exec: ${cmd}`);
473-
return cp.execSync(cmd).toString().trim();
474-
}
475-
const version = exec("git describe --tags --always");
476-
477476
const compilerVersion = getCompilerVersion();
478477
console.log("Found compiler version", compilerVersion);
479478
const staticCompilerVersion = getCompilerVersion("static.esy");
480479
console.log("Found static compiler version", staticCompilerVersion);
481480

481+
const version = cli("git describe --tags --always");
482+
482483
const packageJson = JSON.stringify(
483484
{
484485
name: mainPackageJson.name,

0 commit comments

Comments
 (0)