Skip to content

Commit

Permalink
feat(bin): removes --node argument
Browse files Browse the repository at this point in the history
  • Loading branch information
rafamel committed Apr 30, 2019
1 parent 583c6ad commit cc072b9
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions src/bin/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@ export default async function main(argv: string[]): Promise<void> {
Options:
-f, --file <path> Configuration file
-d, --dir <path> Project directory
-e, --env <value> Environment variables
-e, --env <value> Environment variables for spawned processes
-s, --silent Silent fail -exits with code 0 on error
--log <level> Logging level
--node <value> Sets node environment, shorthand for -e NODE_ENV=
-h, --help Show help
-v, --version Show version number
Expand All @@ -50,7 +49,6 @@ export default async function main(argv: string[]): Promise<void> {
'--env': [String] as [StringConstructor],
'--silent': Boolean,
'--log': String,
'--node': String,
'--help': Boolean,
'--version': Boolean
};
Expand All @@ -72,17 +70,14 @@ export default async function main(argv: string[]): Promise<void> {
directory: cmd['--dir'],
silent: cmd['--silent'],
log: cmd['--log'] as TLogger,
// TODO these should be set in process.env so when required, the js has them
env: (cmd['--env'] || [])
.concat(cmd['--node'] ? `NODE_ENV=${cmd['--node']}` : [])
.reduce((acc: IOfType<string>, str) => {
const arr = str.split('=');
if (arr.length !== 2) {
throw Error(`Environment variables must have format VARIABLE=value`);
}
acc[arr[0]] = arr[1];
return acc;
}, {})
env: (cmd['--env'] || []).reduce((acc: IOfType<string>, str) => {
const arr = str.split('=');
if (arr.length !== 2) {
throw Error(`Environment variables must have format VARIABLE=value`);
}
acc[arr[0]] = arr[1];
return acc;
}, {})
});

let first = cmd._.shift();
Expand Down

0 comments on commit cc072b9

Please sign in to comment.