Skip to content

Commit 761b69a

Browse files
edisigcidustinbyrne
authored andcommitted
fix: Check APPMAP_RECORDER_PROCESS_ALWAYS truthy value
This commit updates the interpretation of the APPMAP_RECORDER_PROCESS_ALWAYS environment variable so that process recording remains active only if the variable is set to a truthy value (one of ‘true’, ‘1’, ‘on’, ‘yes’). Previously, the existence of the APPMAP_RECORDER_PROCESS_ALWAYS environment variable, regardless of its value, was interpreted as true.
1 parent ad5cd8d commit 761b69a

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/recorder.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,16 @@ import { FunctionInfo } from "./registry";
1010
import commonPathPrefix from "./util/commonPathPrefix";
1111
import { getTime } from "./util/getTime";
1212

13-
const processRecordingShouldAlwaysBeActive = "APPMAP_RECORDER_PROCESS_ALWAYS" in process.env;
13+
const kAppmapRecorderProcessAlwaysEnvar = "APPMAP_RECORDER_PROCESS_ALWAYS";
14+
const processRecordingShouldAlwaysBeActive = isTruthy(
15+
process.env[kAppmapRecorderProcessAlwaysEnvar],
16+
);
17+
18+
function isTruthy(value?: string): boolean {
19+
if (value == undefined) return false;
20+
const truthyValues = ["true", "1", "on", "yes"];
21+
return truthyValues.includes(value.toLowerCase().trim());
22+
}
1423

1524
// If APPMAP_RECORDER_PROCESS_ALWAYS is set we can have
1625
// two recordings active simultaneously. Always active

0 commit comments

Comments
 (0)