@mono-labs/cli 0.0.178 → 0.0.179
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.
- package/package.json +1 -1
- package/src/expo.js +23 -1
package/package.json
CHANGED
package/src/expo.js
CHANGED
|
@@ -1,4 +1,26 @@
|
|
|
1
|
-
export
|
|
1
|
+
export function replaceTokens(str, env) {
|
|
2
|
+
if (typeof str !== 'string') return str;
|
|
3
|
+
|
|
4
|
+
return str.replace(/\$\{([^}]+)\}|\$([A-Z0-9_]+)/g, (m, k1, k2) => {
|
|
5
|
+
const k = k1 || k2;
|
|
6
|
+
|
|
7
|
+
// existing data layer takes priority (guarded in case not defined)
|
|
8
|
+
if (typeof hasData === 'function' && hasData(k)) {
|
|
9
|
+
const val = typeof getData === 'function' ? getData(k) : undefined;
|
|
10
|
+
return val == null ? '' : String(val);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// environment variables
|
|
14
|
+
if (env && Object.prototype.hasOwnProperty.call(env, k)) {
|
|
15
|
+
const val = env[k];
|
|
16
|
+
return val == null ? '' : String(val);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// fallback
|
|
20
|
+
return '';
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
2
24
|
function filterEnvByPrefix(env, prefix) {
|
|
3
25
|
const filtered = {};
|
|
4
26
|
for (const key in env) {
|