Skip to content

Commit 2b8f4b3

Browse files
authored
Merge pull request #65 from zhongzhi107/master
feat: Support more dotenv options
2 parents 7f93c94 + 8cbd7e0 commit 2b8f4b3

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,22 @@ using the shorter alias
123123
}
124124
```
125125

126-
Also for silence output, you can use `-s` or verbose `--silence` flags
126+
And for silence output, you can use `-s` or verbose `--silence` flags
127127

128128
```
129129
bnr watch-client -s
130130
```
131+
132+
And you can use `-p` or verbose `--path` to specify a custom path of dotenv file
133+
134+
```
135+
bnr start-dev --path=/custom/path/to/your/env/vars
136+
```
137+
138+
Also use `-e` or verbose `--encoding` to specify the encoding of dotenv file
139+
140+
```
141+
bnr start-dev --encoding=base64
142+
```
143+
144+
See [envdot docs](https://github.com/motdotla/dotenv) for more infomation

index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ var program = require('commander'),
33
scriptName = process.argv[2];
44

55
program
6+
.option('-e, --encoding [type]', 'Specify the encoding of dotenv file')
7+
.option('-p, --path [type]', 'Specify a custom path of dotenv file')
68
.option('-s, --silent', 'silent')
79
.parse(process.argv);
810

@@ -42,4 +44,3 @@ exec(pkg.betterScripts[scriptName], program, function (error, stdout, stderr) {
4244
console.log('exec error: '+error);
4345
}
4446
});
45-

lib/exec.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1-
require('dotenv').config({silent: true});
2-
31
var spawn = require('child_process').spawn,
42
objectAssign = require('object-assign');
53

64
module.exports = function exec(script, program) {
5+
var dotenvConfig = objectAssign({ silent: true }, {
6+
encoding: program.encoding,
7+
path: program.path
8+
});
9+
10+
require('dotenv').config(dotenvConfig);
711

812
var argv = process.argv.splice(3),
913
command = (typeof script === 'string' ? script : script.command) + ' ' + argv.join(' ');

0 commit comments

Comments
 (0)