Skip to content

Commit

Permalink
Merge pull request #65 from zhongzhi107/master
Browse files Browse the repository at this point in the history
feat: Support more dotenv options
  • Loading branch information
benoror authored Mar 20, 2017
2 parents 7f93c94 + 8cbd7e0 commit 2b8f4b3
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,22 @@ using the shorter alias
}
```

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

```
bnr watch-client -s
```

And you can use `-p` or verbose `--path` to specify a custom path of dotenv file

```
bnr start-dev --path=/custom/path/to/your/env/vars
```

Also use `-e` or verbose `--encoding` to specify the encoding of dotenv file

```
bnr start-dev --encoding=base64
```

See [envdot docs](https://github.com/motdotla/dotenv) for more infomation
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ var program = require('commander'),
scriptName = process.argv[2];

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

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

8 changes: 6 additions & 2 deletions lib/exec.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
require('dotenv').config({silent: true});

var spawn = require('child_process').spawn,
objectAssign = require('object-assign');

module.exports = function exec(script, program) {
var dotenvConfig = objectAssign({ silent: true }, {
encoding: program.encoding,
path: program.path
});

require('dotenv').config(dotenvConfig);

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

0 comments on commit 2b8f4b3

Please sign in to comment.