diff options
| author | Olcan <[email protected]> | 2025-05-02 08:15:46 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-05-02 08:15:46 -0700 |
| commit | a7679db6e99f971306bc4b27c603e93bc67ac254 (patch) | |
| tree | b123af46cbcc119434ddc0cc3d6f5b10d5637601 /packages/cli/src/utils/sandbox.ts | |
| parent | 53ac7952c7ac11770037fecccda5f0f2fffa3e0b (diff) | |
sandbox setting and argument (#243)
Diffstat (limited to 'packages/cli/src/utils/sandbox.ts')
| -rw-r--r-- | packages/cli/src/utils/sandbox.ts | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/packages/cli/src/utils/sandbox.ts b/packages/cli/src/utils/sandbox.ts index ceaf8726..40fca09c 100644 --- a/packages/cli/src/utils/sandbox.ts +++ b/packages/cli/src/utils/sandbox.ts @@ -15,9 +15,13 @@ import { } from '../config/settings.js'; // node.js equivalent of scripts/sandbox_command.sh -export function sandbox_command(): string { - const sandbox = process.env.GEMINI_CODE_SANDBOX?.toLowerCase().trim() ?? ''; - if (['1', 'true'].includes(sandbox)) { +export function sandbox_command(sandbox?: string | boolean): string { + // note environment variable takes precedence over argument (from command line or settings) + sandbox = process.env.GEMINI_CODE_SANDBOX?.toLowerCase().trim() ?? sandbox; + if (sandbox === '1' || sandbox === 'true') sandbox = true; + else if (sandbox === '0' || sandbox === 'false') sandbox = false; + + if (sandbox === true) { // look for docker or podman, in that order if (execSync('command -v docker || true').toString().trim()) { return 'docker'; // Set sandbox to 'docker' if found |
