@snowyroad/braid 0.82.0 → 0.83.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,32 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/envAlias.ts
4
+ var LEGACY_PREFIX = "ARP_";
5
+ var NEW_PREFIX = "BRAID_";
6
+ var EXCLUDED_LEGACY_PREFIX = "ARP_TUI_";
7
+ var warned = false;
8
+ function applyEnvAliases(env = process.env, stderr = process.stderr) {
9
+ const honored = [];
10
+ for (const key of Object.keys(env)) {
11
+ if (!key.startsWith(LEGACY_PREFIX)) continue;
12
+ if (key.startsWith(EXCLUDED_LEGACY_PREFIX)) continue;
13
+ const value = env[key];
14
+ if (value === void 0) continue;
15
+ const newKey = NEW_PREFIX + key.slice(LEGACY_PREFIX.length);
16
+ if (env[newKey] !== void 0) continue;
17
+ env[newKey] = value;
18
+ honored.push(key);
19
+ }
20
+ if (honored.length > 0 && !warned) {
21
+ warned = true;
22
+ stderr.write(
23
+ `[braid] deprecation: legacy ${LEGACY_PREFIX}* environment variables detected (${honored.sort().join(", ")}) \u2014 rename them to ${NEW_PREFIX}*; the legacy names keep working for now but will be removed in a future release.
24
+ `
25
+ );
26
+ }
27
+ return honored;
28
+ }
29
+
30
+ export {
31
+ applyEnvAliases
32
+ };