@karmaniverous/get-dotenv 1.0.0 → 1.1.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.
package/bin/getdotenv/index.js
CHANGED
|
@@ -22,13 +22,14 @@ program
|
|
|
22
22
|
`* Specify the directories containing your dotenv files.`,
|
|
23
23
|
`* Specify the token that identifies dotenv files (e.g. '.env').`,
|
|
24
24
|
`* Specify the token that identifies private vatiables (e.g. '.local').`,
|
|
25
|
+
`* Load variables for a specific environment or none.`,
|
|
25
26
|
`* Specify a default environment, override the default with an existing`,
|
|
26
27
|
` environment variable, and override both with a direct setting.`,
|
|
27
28
|
`* Exclude public or private variables.`,
|
|
28
29
|
`* Define dynamic variables progressively in terms of other variables and`,
|
|
29
30
|
` other logic.`,
|
|
30
|
-
`* Execute a shell
|
|
31
|
-
`* Place the shell
|
|
31
|
+
`* Execute a &&-delimited series of shell commands after loading variables.`,
|
|
32
|
+
`* Place the shell commands inside the invocation to support npm script`,
|
|
32
33
|
` arguments for other options.`,
|
|
33
34
|
].join('\n')
|
|
34
35
|
);
|
|
@@ -92,18 +93,10 @@ await getDotenv({
|
|
|
92
93
|
|
|
93
94
|
// Execute shell command.
|
|
94
95
|
if (command || program.args.length) {
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
|
|
96
|
+
const argvs = (command ?? program.args.join(' '))
|
|
97
|
+
.split('&&')
|
|
98
|
+
.map((c) => parseArgsStringToArgv(c));
|
|
98
99
|
|
|
99
|
-
|
|
100
|
-
'
|
|
101
|
-
function (exitCode, signal) {
|
|
102
|
-
if (typeof exitCode === 'number') {
|
|
103
|
-
process.exit(exitCode);
|
|
104
|
-
} else {
|
|
105
|
-
process.kill(process.pid, signal);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
);
|
|
100
|
+
for (const argv of argvs)
|
|
101
|
+
spawn.sync(argv[0], argv.slice(1), { stdio: 'inherit' });
|
|
109
102
|
}
|
|
@@ -73,7 +73,7 @@ const getDotenv = async function () {
|
|
|
73
73
|
if (error) throw new Error(error);
|
|
74
74
|
|
|
75
75
|
// Process dynamic variables.
|
|
76
|
-
if (dynamicPath) {
|
|
76
|
+
if (!excludePublic && dynamicPath) {
|
|
77
77
|
const dynamic = new Function(`return ${(await _fsExtra.default.readFile(dynamicPath)).toString()}`)()(dotenv);
|
|
78
78
|
Object.keys(dynamic).forEach(key => {
|
|
79
79
|
Object.assign(dotenv, {
|
|
@@ -79,7 +79,7 @@ export const getDotenv = async ({
|
|
|
79
79
|
if (error) throw new Error(error);
|
|
80
80
|
|
|
81
81
|
// Process dynamic variables.
|
|
82
|
-
if (dynamicPath) {
|
|
82
|
+
if (!excludePublic && dynamicPath) {
|
|
83
83
|
const dynamic = new Function(
|
|
84
84
|
`return ${(await fs.readFile(dynamicPath)).toString()}`
|
|
85
85
|
)()(dotenv);
|