@incanta/config 2.0.5 → 2.0.6
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/lib/config-env.js +7 -4
- package/lib/config-env.js.map +1 -1
- package/package.json +1 -1
- package/src/config-env.ts +8 -4
package/lib/config-env.js
CHANGED
|
@@ -9,10 +9,10 @@ const lodash_mergewith_1 = __importDefault(require("lodash.mergewith"));
|
|
|
9
9
|
const index_1 = __importDefault(require("./index"));
|
|
10
10
|
const merge_customizer_1 = require("./merge-customizer");
|
|
11
11
|
let command = process.argv.slice(2).join(" ");
|
|
12
|
+
let envName = "";
|
|
12
13
|
if (command.startsWith("--env=") || command.startsWith("-e=")) {
|
|
13
14
|
const isLongOption = command.startsWith("--env=");
|
|
14
15
|
const commandAfterEnv = command.substring(command.indexOf(isLongOption ? "--env=" : "-e=") + (isLongOption ? 6 : 3));
|
|
15
|
-
let env = "";
|
|
16
16
|
if (commandAfterEnv.startsWith('"') || commandAfterEnv.startsWith("'")) {
|
|
17
17
|
const quoteChar = commandAfterEnv[0];
|
|
18
18
|
// find next quoteChar, ensuring it wasn't escaped
|
|
@@ -29,21 +29,24 @@ if (command.startsWith("--env=") || command.startsWith("-e=")) {
|
|
|
29
29
|
}
|
|
30
30
|
startQuoteIndex = endQuoteIndex;
|
|
31
31
|
}
|
|
32
|
-
|
|
32
|
+
envName = commandAfterEnv.substring(1, endQuoteIndex).trim();
|
|
33
33
|
command = commandAfterEnv.substring(endQuoteIndex + 1).trim();
|
|
34
34
|
index_1.default.init({
|
|
35
35
|
configDir: index_1.default.dir(),
|
|
36
|
-
configEnv:
|
|
36
|
+
configEnv: envName,
|
|
37
37
|
cwd: index_1.default.cwd(),
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
40
|
else {
|
|
41
41
|
const tokens = commandAfterEnv.split(" ");
|
|
42
|
-
|
|
42
|
+
envName = tokens[0].trim();
|
|
43
43
|
command = tokens.slice(1).join(" ").trim();
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
const env = {};
|
|
47
|
+
if (envName) {
|
|
48
|
+
env.NODE_CONFIG_ENV = envName;
|
|
49
|
+
}
|
|
47
50
|
(0, lodash_mergewith_1.default)(env, process.env, index_1.default.getConfiguredEnv(), merge_customizer_1.mergeWithCustomizer);
|
|
48
51
|
(0, child_process_1.execSync)(command, {
|
|
49
52
|
env,
|
package/lib/config-env.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-env.js","sourceRoot":"","sources":["../src/config-env.ts"],"names":[],"mappings":";;;;;;AAEA,iDAAyC;AACzC,wEAAyC;AACzC,oDAA6B;AAC7B,yDAAyD;AAEzD,IAAI,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAE9C,IAAI,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE;IAC7D,MAAM,YAAY,GAAG,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;IAElD,MAAM,eAAe,GAAG,OAAO,CAAC,SAAS,CACvC,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAC1E,CAAC;IAEF,IAAI,
|
|
1
|
+
{"version":3,"file":"config-env.js","sourceRoot":"","sources":["../src/config-env.ts"],"names":[],"mappings":";;;;;;AAEA,iDAAyC;AACzC,wEAAyC;AACzC,oDAA6B;AAC7B,yDAAyD;AAEzD,IAAI,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAE9C,IAAI,OAAO,GAAG,EAAE,CAAC;AACjB,IA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AAM,CAAC,GAAG,EAAE;YACvB,SAAS,EAAE,OAAO;YAClB,GAAG,EAAE,eAAM,CAAC,GAAG,EAAE;SAClB,CAAC,CAAC;KACJ;SAAM;QACL,MAAM,MAAM,GAAG,eAAe,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC1C,OAAO,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QAC3B,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;KAC5C;CACF;AAED,MAAM,GAAG,GAAQ,EAAE,CAAC;AAEpB,IAAI,OAAO,EAAE;IACX,GAAG,CAAC,eAAe,GAAG,OAAO,CAAC;CAC/B;AAED,IAAA,0BAAS,EAAC,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,eAAM,CAAC,gBAAgB,EAAE,EAAE,sCAAmB,CAAC,CAAC;AAE5E,IAAA,wBAAQ,EAAC,OAAO,EAAE;IAChB,GAAG;IACH,KAAK,EAAE,SAAS;CACjB,CAAC,CAAC"}
|
package/package.json
CHANGED
package/src/config-env.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { mergeWithCustomizer } from "./merge-customizer";
|
|
|
7
7
|
|
|
8
8
|
let command = process.argv.slice(2).join(" ");
|
|
9
9
|
|
|
10
|
+
let envName = "";
|
|
10
11
|
if (command.startsWith("--env=") || command.startsWith("-e=")) {
|
|
11
12
|
const isLongOption = command.startsWith("--env=");
|
|
12
13
|
|
|
@@ -14,7 +15,6 @@ if (command.startsWith("--env=") || command.startsWith("-e=")) {
|
|
|
14
15
|
command.indexOf(isLongOption ? "--env=" : "-e=") + (isLongOption ? 6 : 3)
|
|
15
16
|
);
|
|
16
17
|
|
|
17
|
-
let env = "";
|
|
18
18
|
if (commandAfterEnv.startsWith('"') || commandAfterEnv.startsWith("'")) {
|
|
19
19
|
const quoteChar = commandAfterEnv[0];
|
|
20
20
|
// find next quoteChar, ensuring it wasn't escaped
|
|
@@ -37,23 +37,27 @@ if (command.startsWith("--env=") || command.startsWith("-e=")) {
|
|
|
37
37
|
startQuoteIndex = endQuoteIndex;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
envName = commandAfterEnv.substring(1, endQuoteIndex).trim();
|
|
41
41
|
command = commandAfterEnv.substring(endQuoteIndex + 1).trim();
|
|
42
42
|
|
|
43
43
|
config.init({
|
|
44
44
|
configDir: config.dir(),
|
|
45
|
-
configEnv:
|
|
45
|
+
configEnv: envName,
|
|
46
46
|
cwd: config.cwd(),
|
|
47
47
|
});
|
|
48
48
|
} else {
|
|
49
49
|
const tokens = commandAfterEnv.split(" ");
|
|
50
|
-
|
|
50
|
+
envName = tokens[0].trim();
|
|
51
51
|
command = tokens.slice(1).join(" ").trim();
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
const env: any = {};
|
|
56
56
|
|
|
57
|
+
if (envName) {
|
|
58
|
+
env.NODE_CONFIG_ENV = envName;
|
|
59
|
+
}
|
|
60
|
+
|
|
57
61
|
mergeWith(env, process.env, config.getConfiguredEnv(), mergeWithCustomizer);
|
|
58
62
|
|
|
59
63
|
execSync(command, {
|