dotenv-diff 2.3.0 → 2.3.1
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadConfig.d.ts","sourceRoot":"","sources":["../../../src/config/loadConfig.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAG7C
|
|
1
|
+
{"version":3,"file":"loadConfig.d.ts","sourceRoot":"","sources":["../../../src/config/loadConfig.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAG7C;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,UAAU,EAAE,OAAO,CAAC,UAAU,CAAC,GAAG,UAAU,CAgCtE"}
|
|
@@ -3,6 +3,7 @@ import path from "path";
|
|
|
3
3
|
import { printConfigLoaded, printConfigLoadError } from "../ui/shared/printConfigStatus.js";
|
|
4
4
|
/**
|
|
5
5
|
* Loads dotenv-diff.config.json (if present)
|
|
6
|
+
* Searches upward for config
|
|
6
7
|
* and merges it with CLI flags.
|
|
7
8
|
* CLI options always take precedence.
|
|
8
9
|
* @param cliOptions - Options provided via CLI
|
|
@@ -10,13 +11,23 @@ import { printConfigLoaded, printConfigLoadError } from "../ui/shared/printConfi
|
|
|
10
11
|
*/
|
|
11
12
|
export function loadConfig(cliOptions) {
|
|
12
13
|
const cwd = process.cwd();
|
|
13
|
-
|
|
14
|
+
// Recursive search upwards for dotenv-diff.config.json
|
|
15
|
+
function findConfigFile(dir) {
|
|
16
|
+
const configPath = path.join(dir, "dotenv-diff.config.json");
|
|
17
|
+
if (fs.existsSync(configPath))
|
|
18
|
+
return configPath;
|
|
19
|
+
const parent = path.dirname(dir);
|
|
20
|
+
if (parent !== dir)
|
|
21
|
+
return findConfigFile(parent);
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
const foundPath = findConfigFile(cwd);
|
|
14
25
|
let fileConfig = {};
|
|
15
|
-
if (
|
|
26
|
+
if (foundPath) {
|
|
16
27
|
try {
|
|
17
|
-
const raw = fs.readFileSync(
|
|
28
|
+
const raw = fs.readFileSync(foundPath, "utf8");
|
|
18
29
|
fileConfig = JSON.parse(raw);
|
|
19
|
-
printConfigLoaded(
|
|
30
|
+
printConfigLoaded(foundPath);
|
|
20
31
|
}
|
|
21
32
|
catch (err) {
|
|
22
33
|
printConfigLoadError(err);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadConfig.js","sourceRoot":"","sources":["../../../src/config/loadConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AAE5F
|
|
1
|
+
{"version":3,"file":"loadConfig.js","sourceRoot":"","sources":["../../../src/config/loadConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AAE5F;;;;;;;GAOG;AACH,MAAM,UAAU,UAAU,CAAC,UAA+B;IACxD,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAE1B,uDAAuD;IACvD,SAAS,cAAc,CAAC,GAAW;QACjC,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,yBAAyB,CAAC,CAAC;QAC7D,IAAI,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC;YAAE,OAAO,UAAU,CAAC;QAEjD,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACjC,IAAI,MAAM,KAAK,GAAG;YAAE,OAAO,cAAc,CAAC,MAAM,CAAC,CAAC;QAClD,OA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