@shophost/rest-api 2.0.22 → 2.0.23
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
CHANGED
|
@@ -59,6 +59,34 @@ function getDbPushArgs(argv) {
|
|
|
59
59
|
return argv.slice(2);
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
+
function expandEnvValue(value, env) {
|
|
63
|
+
return value.replace(
|
|
64
|
+
/\\?\$(?:\{([A-Za-z_][A-Za-z0-9_]*)\}|([A-Za-z_][A-Za-z0-9_]*))/g,
|
|
65
|
+
(match, bracedName, plainName) => {
|
|
66
|
+
if (match.startsWith("\\")) {
|
|
67
|
+
return match.slice(1);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const variableName = bracedName ?? plainName;
|
|
71
|
+
return env[variableName] ?? "";
|
|
72
|
+
}
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function applyParsedEnv(parsed, shouldOverride) {
|
|
77
|
+
if (!parsed) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
for (const [key, rawValue] of Object.entries(parsed)) {
|
|
82
|
+
if (!shouldOverride && process.env[key] !== undefined) {
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
process.env[key] = expandEnvValue(rawValue, process.env);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
62
90
|
function loadEnvFiles() {
|
|
63
91
|
for (const envFile of [".env", ".env.local"]) {
|
|
64
92
|
const envPath = join(process.cwd(), envFile);
|
|
@@ -67,10 +95,12 @@ function loadEnvFiles() {
|
|
|
67
95
|
continue;
|
|
68
96
|
}
|
|
69
97
|
|
|
70
|
-
dotenv.config({
|
|
98
|
+
const result = dotenv.config({
|
|
71
99
|
path: envPath,
|
|
72
100
|
override: envFile === ".env.local",
|
|
73
101
|
});
|
|
102
|
+
|
|
103
|
+
applyParsedEnv(result.parsed, envFile === ".env.local");
|
|
74
104
|
}
|
|
75
105
|
}
|
|
76
106
|
|