diff --git a/README.md b/README.md index 433ed55..124cdfc 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ Options: -u, --update Rewrite expected output in-place with actual output -k, --keep Keep temp directories after run --clean-env Start with empty environment - --bin Prepend to PATH + --path Prepend to PATH (repeatable) --timeout Per-command timeout (default: "10s") -v, --verbose Print each command as it runs --parallel Run files in parallel diff --git a/SPEC.md b/SPEC.md index 7494ce1..de8f7fc 100644 --- a/SPEC.md +++ b/SPEC.md @@ -61,7 +61,7 @@ The following environment variables are set for every command: | Variable | Value | |---|---| | `HOME` | the temp directory | -| `PATH` | inherited from host (or prepended via `--bin`) | +| `PATH` | inherited from host (or prepended via `--path`) | | `CUE_DIR` | the temp directory | All other environment variables are inherited from the host unless explicitly @@ -99,7 +99,7 @@ and subdirectories. Each command in each shout file is run sequentially | `--update` / `-u` | Rewrite expected output in-place with actual output | | `--keep` / `-k` | Keep temp directories after run (printed to stderr) | | `--clean-env` | Start with empty environment (only `PATH` and `CUE_DIR` set) | -| `--bin ` | Prepend `` to `PATH` | +| `--path ` | Prepend `` to `PATH` (repeatable) | | `--timeout ` | Per-command timeout, e.g. `500ms`, `10s`, `1m` (default: `10s`) | | `--verbose` / `-v` | Print each command as it runs | | `--parallel` | Run files in parallel (implies all files run regardless of failures) | diff --git a/src/cli/index.ts b/src/cli/index.ts index d2e7149..4405516 100755 --- a/src/cli/index.ts +++ b/src/cli/index.ts @@ -50,7 +50,7 @@ program .option("-u, --update", "Rewrite expected output in-place with actual output") .option("-k, --keep", "Keep temp directories after run") .option("--clean-env", "Start with empty environment") - .option("--bin ", "Prepend to PATH") + .option("--path ", "Prepend to PATH (repeatable)", (val: string, acc: string[]) => [...acc, val], [] as string[]) .option("--timeout ", "Per-command timeout", "10s") .option("-v, --verbose", "Print each command as it runs") .option("--parallel", "Run files in parallel") @@ -95,7 +95,7 @@ $ true const fileResult = await runFile(parsed, { cleanEnv: opts.cleanEnv ?? false, - binPath: opts.bin, + pathDirs: opts.path.length > 0 ? opts.path : undefined, timeout: timeoutMs, verbose: opts.verbose ?? false, onCommand: opts.verbose diff --git a/src/run.ts b/src/run.ts index 23d1850..001ac4d 100644 --- a/src/run.ts +++ b/src/run.ts @@ -19,7 +19,7 @@ export type FileResult = { type RunOptions = { cleanEnv: boolean - binPath?: string + pathDirs?: string[] timeout: number verbose: boolean onCommand?: (cmd: Command) => void @@ -128,8 +128,8 @@ export async function runFile( env["HOME"] = tmpDir env["CUE_DIR"] = tmpDir - if (options.binPath) { - env["PATH"] = options.binPath + ":" + (env["PATH"] ?? "") + if (options.pathDirs?.length) { + env["PATH"] = options.pathDirs.join(":") + ":" + (env["PATH"] ?? "") } try {