Skip to content

Commit

Permalink
fixup! feat(cli): build based on configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
tuler committed Oct 9, 2024
1 parent 29c293c commit 06d61ce
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions apps/cli/src/exec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { spawnSync, SpawnSyncOptions } from "child_process";
import { execa, ExecaError, Options } from "execa";
import os from "os";

/**
* Calls execa and falls back to docker run if command (on the host) fails
Expand All @@ -22,18 +23,18 @@ export const execaDockerFallback = async (
console.warn(
`error executing '${command}', falling back to docker execution using image '${options.image}'`,
);
const userInfo = os.userInfo();
const dockerOpts = [
"--volume",
`${options.cwd}:/work`,
"--workdir",
"/work",
"--user",
userInfo.uid.toString(),
];
return await execa(
"docker",
[
"run",
"--volume",
`${options.cwd}:/work`,
"--workdir",
"/work",
options.image,
command,
...args,
],
["run", ...dockerOpts, options.image, command, ...args],
options,
);
} else {
Expand Down Expand Up @@ -64,12 +65,15 @@ export const spawnSyncDockerFallback = async (
console.warn(
`error executing '${command}', falling back to docker execution using image '${options.image}'`,
);
const userInfo = os.userInfo();
const dockerOpts = [
"--volume",
`${options.cwd}:/work`,
"--workdir",
"/work",
"--interactive",
"--user",
userInfo.uid.toString(),
];
const dockerArgs = [
"run",
Expand Down

0 comments on commit 06d61ce

Please sign in to comment.