From 3001c43b7b9c819a33ee084bd985a18e462042dc Mon Sep 17 00:00:00 2001 From: segersniels Date: Thu, 23 May 2019 17:21:42 +0200 Subject: [PATCH] :ambulance: Fix mapping of flags if no flags defined --- package.json | 2 +- src/index.ts | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 2f1ccecb..97c80887 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "supdock", - "version": "2.0.3", + "version": "2.0.4", "description": "What's Up Dock(er)?", "main": "index.js", "scripts": { diff --git a/src/index.ts b/src/index.ts index a3b431b1..c30b2c7a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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); } } @@ -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[] {