Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't pass bnr flags to specified command #70

Merged
merged 1 commit into from Jul 31, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Expand Up @@ -126,19 +126,19 @@ using the shorter alias
And for silence output, you can use `-s` or verbose `--silence` flags

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

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
bnr --path=/custom/path/to/your/env/vars start-dev
```

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

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

See [envdot docs](https://github.com/motdotla/dotenv) for more infomation
4 changes: 2 additions & 2 deletions index.js
@@ -1,12 +1,12 @@
#!/usr/bin/env node
var program = require('commander'),
scriptName = process.argv[2];
var program = require('commander');

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);
var scriptName = program.args[0];

if (!program.silent) {
console.log('running better-npm-run in', process.cwd());
Expand Down
7 changes: 6 additions & 1 deletion lib/exec.js
Expand Up @@ -9,7 +9,12 @@ module.exports = function exec(script, program) {

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

var argv = process.argv.splice(3),
var argvIndex = -1;
firstArg = program.args[0];
if (firstArg !== undefined) {
argvIndex = process.argv.indexOf(firstArg);
}
var argv = argvIndex === -1 ? [] : process.argv.splice(argvIndex + 1),
command = (typeof script === 'string' ? script : script.command) + ' ' + argv.join(' ');

script.env = script.env || {};
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -20,7 +20,7 @@
"scripts": {
"test:env": "node index.js test:env",
"test:env-extend": "TEST_ENV2=envvar node index.js test:env-extend",
"test:params": "node index.js test:params --test",
"test:params": "node index.js --silent test:params --test",
"test:command:object": "node index.js test:command:object",
"test:command:string": "node index.js test:command:string",
"test:silent": "node index.js test:command:object -s && node index.js test:command:object --silent",
Expand Down
3 changes: 3 additions & 0 deletions test/params.js
@@ -1,3 +1,6 @@
if (process.argv[2] === "--silent") {
throw new Error('it should eat extra arguments');
}
if (process.argv[2] !== "--test") {
throw new Error('it should accept params');
}