Skip to content

Commit

Permalink
🚑 Fix mapping of flags if no flags defined
Browse files Browse the repository at this point in the history
  • Loading branch information
segersniels committed May 23, 2019
1 parent 5589c7a commit 3001c43
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "supdock",
"version": "2.0.3",
"version": "2.0.4",
"description": "What's Up Dock(er)?",
"main": "index.js",
"scripts": {
Expand Down
13 changes: 10 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,12 @@ export default class Supdock {
`);
} else {
this.default();
logAndForget(`\nCustom:\n${this.generateFlagDescriptions(command)}`);
const flagDescriptions = this.generateFlagDescriptions(command);
// Only log extra stuff if there are actual custom flags for the command
if (flagDescriptions.length > 0) {
logAndForget(`\nCustom:\n${flagDescriptions}`);
}
process.exit(0);
}
}

Expand All @@ -99,8 +104,10 @@ export default class Supdock {

private generateFlagDescriptions(command: string) {
return this.commands[command].flags
.map((flag: string) => ` ${flag}`)
.join('\n');
? this.commands[command].flags
.map((flag: string) => ` ${flag}`)
.join('\n')
: '';
}

private executeFullyDeclaredCommand(command: string): string[] {
Expand Down

0 comments on commit 3001c43

Please sign in to comment.