Skip to content

Commit 04a90e8

Browse files
committed
Fix environment variable parsing to handle values with equals signs
1 parent 0281e5f commit 04a90e8

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

bin/cli.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,21 @@ async function main() {
2727
}
2828

2929
if (parsingFlags && arg === "-e" && i + 1 < args.length) {
30-
const [key, value] = args[++i].split("=");
31-
if (key && value) {
30+
// Parse environment variables passed with -e flag
31+
// Format: -e KEY=VALUE
32+
// Example: -e MY_VAR=my_value
33+
// Handles env vars where VALUE can contain "=" signs (e.g., var1=sample=value)
34+
const envVar = args[++i];
35+
const equalsIndex = envVar.indexOf("=");
36+
37+
if (equalsIndex !== -1) {
38+
// Split only at the first equals sign
39+
const key = envVar.substring(0, equalsIndex);
40+
const value = envVar.substring(equalsIndex + 1);
3241
envVars[key] = value;
42+
} else {
43+
// No equals sign found, use the whole string as key with empty value
44+
envVars[envVar] = "";
3345
}
3446
} else if (!command) {
3547
command = arg;
@@ -113,4 +125,4 @@ main()
113125
.catch((e) => {
114126
console.error(e);
115127
process.exit(1);
116-
});
128+
});

0 commit comments

Comments
 (0)