@karmaniverous/get-dotenv 2.3.4 → 2.4.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/README.md +22 -12
- package/bin/getdotenv/index.js +14 -3
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -77,23 +77,33 @@ dotenv files. You can:
|
|
|
77
77
|
* Load variables for a specific environment or none.
|
|
78
78
|
* Specify a default environment, override the default with an existing
|
|
79
79
|
environment variable, and override both with a direct setting.
|
|
80
|
+
* Derive the default environment from the current git branch
|
|
80
81
|
* Exclude public, private, global, environment-specific, or dynamic variables.
|
|
81
82
|
* Execute a &&-delimited series of shell commands after loading variables,
|
|
82
83
|
optionally ignoring errors.
|
|
83
84
|
* Place the shell commands inside the invocation to support npm script
|
|
84
85
|
arguments for other options.
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
-
|
|
90
|
-
-
|
|
91
|
-
-
|
|
92
|
-
-
|
|
93
|
-
-
|
|
94
|
-
-
|
|
95
|
-
-
|
|
96
|
-
-
|
|
86
|
+
* Specify the token that identifies dotenv files (e.g. '.env').
|
|
87
|
+
* Specify the token that identifies private vatiables (e.g. '.local').
|
|
88
|
+
|
|
89
|
+
Options:
|
|
90
|
+
-p, --paths <strings...> space-delimited paths to dotenv directory (default './')
|
|
91
|
+
-y, --dynamic-path <string> dynamic variables path
|
|
92
|
+
-o, --output-path <string> consolidated output file (follows dotenv-expand rules using loaded env vars)
|
|
93
|
+
-d, --default-environment <string> default environment (prefix with $ to use environment variable)
|
|
94
|
+
-b, --branch-to-default derive default environment from the current git branch (default: false)
|
|
95
|
+
-e, --environment <string> designated environment (prefix with $ to use environment variable)
|
|
96
|
+
-n, --exclude-env exclude environment-specific variables (default: false)
|
|
97
|
+
-g, --exclude-global exclude global & dynamic variables (default: false)
|
|
98
|
+
-r, --exclude-private exclude private variables (default: false)
|
|
99
|
+
-u, --exclude-public exclude public variables (default: false)
|
|
100
|
+
-z, --exclude-dynamic exclude dynamic variables (default: false)
|
|
101
|
+
-c, --command <string> shell command string
|
|
102
|
+
-l, --log log extracted variables (default: false)
|
|
103
|
+
-t, --dotenv-token <string> token indicating a dotenv file (default: '.env')
|
|
104
|
+
-i, --private-token <string> token indicating private variables (default: 'local')
|
|
105
|
+
-q, --quit-on-error terminate sequential process on error (default: false)
|
|
106
|
+
-h, --help display help for command
|
|
97
107
|
```
|
|
98
108
|
|
|
99
109
|
# API Documentation
|
package/bin/getdotenv/index.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
// Import npm packages.
|
|
4
4
|
import spawn from 'cross-spawn';
|
|
5
|
+
import branch from 'git-branch';
|
|
5
6
|
import _ from 'lodash';
|
|
6
7
|
import { parseArgsStringToArgv } from 'string-argv';
|
|
7
8
|
|
|
@@ -32,6 +33,7 @@ program
|
|
|
32
33
|
`* Load variables for a specific environment or none.`,
|
|
33
34
|
`* Specify a default environment, override the default with an existing`,
|
|
34
35
|
` environment variable, and override both with a direct setting.`,
|
|
36
|
+
`* Derive the default environment from the current git branch`,
|
|
35
37
|
`* Exclude public, private, global, environment-specific, or dynamic variables.`,
|
|
36
38
|
`* Execute a &&-delimited series of shell commands after loading variables,`,
|
|
37
39
|
` optionally ignoring errors.`,
|
|
@@ -54,10 +56,15 @@ program
|
|
|
54
56
|
'consolidated output file (follows dotenv-expand rules using loaded env vars)'
|
|
55
57
|
)
|
|
56
58
|
.option(
|
|
57
|
-
'-d, --
|
|
59
|
+
'-d, --default-environment <string>',
|
|
58
60
|
'default environment (prefix with $ to use environment variable)',
|
|
59
61
|
envMerge
|
|
60
62
|
)
|
|
63
|
+
.option(
|
|
64
|
+
'-b, --branch-to-default',
|
|
65
|
+
'derive default environment from the current git branch (default: false)',
|
|
66
|
+
envMerge
|
|
67
|
+
)
|
|
61
68
|
.option(
|
|
62
69
|
'-e, --environment <string>',
|
|
63
70
|
'designated environment (prefix with $ to use environment variable)',
|
|
@@ -92,15 +99,16 @@ program
|
|
|
92
99
|
// Parse CLI options from command line.
|
|
93
100
|
program.parse();
|
|
94
101
|
const {
|
|
102
|
+
branchToDefault,
|
|
95
103
|
command,
|
|
96
104
|
defaultEnvironment,
|
|
97
105
|
dotenvToken,
|
|
106
|
+
dynamicPath,
|
|
98
107
|
environment,
|
|
99
108
|
excludeEnv,
|
|
100
109
|
excludeGlobal,
|
|
101
110
|
excludePrivate,
|
|
102
111
|
excludePublic,
|
|
103
|
-
dynamicPath,
|
|
104
112
|
log,
|
|
105
113
|
outputPath,
|
|
106
114
|
paths,
|
|
@@ -111,7 +119,10 @@ const {
|
|
|
111
119
|
if (command && program.args.length) program.error('command specified twice');
|
|
112
120
|
|
|
113
121
|
// Get environment.
|
|
114
|
-
const env =
|
|
122
|
+
const env =
|
|
123
|
+
environment ??
|
|
124
|
+
defaultEnvironment ??
|
|
125
|
+
(branchToDefault ? branch.sync() : undefined);
|
|
115
126
|
|
|
116
127
|
// Load dotenvs.
|
|
117
128
|
await getDotenv({
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"bin": {
|
|
4
4
|
"getdotenv": "bin/getdotenv/index.js"
|
|
5
5
|
},
|
|
6
|
-
"version": "2.
|
|
6
|
+
"version": "2.4.1",
|
|
7
7
|
"publishConfig": {
|
|
8
8
|
"access": "public"
|
|
9
9
|
},
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
"dotenv": "^16.0.3",
|
|
37
37
|
"dotenv-expand": "^10.0.0",
|
|
38
38
|
"fs-extra": "^11.1.1",
|
|
39
|
+
"git-branch": "^2.0.1",
|
|
39
40
|
"string-argv": "^0.3.2",
|
|
40
41
|
"uuid": "^9.0.0"
|
|
41
42
|
},
|
|
@@ -46,10 +47,10 @@
|
|
|
46
47
|
"@babel/plugin-syntax-import-assertions": "^7.20.0",
|
|
47
48
|
"@babel/preset-env": "^7.21.5",
|
|
48
49
|
"@babel/register": "^7.21.0",
|
|
49
|
-
"@types/node": "^20.
|
|
50
|
+
"@types/node": "^20.2.1",
|
|
50
51
|
"chai": "^4.3.7",
|
|
51
52
|
"concat-md": "^0.5.1",
|
|
52
|
-
"eslint": "^8.
|
|
53
|
+
"eslint": "^8.41.0",
|
|
53
54
|
"eslint-config-standard": "^17.0.0",
|
|
54
55
|
"eslint-plugin-mocha": "^10.1.0",
|
|
55
56
|
"jsdoc-to-markdown": "^8.0.0",
|