Skip to content

Commit

Permalink
fix: don't put multiple newlines between flag summaries in help output (
Browse files Browse the repository at this point in the history
  • Loading branch information
RodEsp committed Aug 6, 2021
1 parent 11cbd6b commit bfbd15c
Show file tree
Hide file tree
Showing 6 changed files with 610 additions and 607 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -96,7 +96,7 @@
"lint": "eslint . --ext .ts --config .eslintrc",
"posttest": "yarn lint",
"prepack": "yarn run build",
"test": "mocha --forbid-only \"test/**/*.test.ts\" --no-color",
"test": "mocha --forbid-only \"test/**/*.test.ts\"",
"pretest": "yarn build --noEmit && tsc -p test --noEmit"
},
"types": "lib/index.d.ts"
Expand Down
4 changes: 2 additions & 2 deletions src/help/formatter.ts
Expand Up @@ -151,8 +151,8 @@ export class HelpFormatter {
}
// if we start putting too many lines down, render in multiline format
if (lines.length > 4) return renderMultiline()
// if spacer is not defined, separate all rows with extra newline
if (!opts.spacer) spacer = '\n\n'
// if spacer is not defined, separate all rows with a newline
if (!opts.spacer) spacer = '\n'
cur += '\n'
cur += this.indent(lines.join('\n'), maxLength + 2)
}
Expand Down
7 changes: 0 additions & 7 deletions test/help/format-command-with-options.test.ts
Expand Up @@ -87,15 +87,11 @@ ARGUMENTS
OPTIONS
-f, --foo=foo foobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoo
barfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobar
-l=label
-r, --remote=remote
--force force it force it force it force it force it force
it force it force it force it force it force it
force it force it force it force it
--ss newliney
newliney
newliney
Expand Down Expand Up @@ -142,13 +138,10 @@ ARGUMENTS
OPTIONS
-f, --foo=foo foobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoo
barfoobarfoobarfoobarfoobarfoobar
-r, --remote=remote
--force force it force it force it force it force it force
it force it force it force it force it force it
force it force it force it force it
--ss newliney
newliney
newliney
Expand Down
7 changes: 0 additions & 7 deletions test/help/format-command.test.ts
Expand Up @@ -66,15 +66,11 @@ ARGUMENTS
FLAGS
-f, --foo=<value> foobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfo
obarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobar
-l=<value>
-r, --remote=<value>
--force force it force it force it force it force it force
it force it force it force it force it force it
force it force it force it force it
--ss newliney
newliney
newliney
Expand Down Expand Up @@ -126,13 +122,10 @@ ARGUMENTS
FLAGS
-f, --foo=<value> foobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfo
obarfoobarfoobarfoobarfoobarfoobar
-r, --remote=<value>
--force force it force it force it force it force it force
it force it force it force it force it force it
force it force it force it force it
--ss newliney
newliney
newliney
Expand Down
3 changes: 2 additions & 1 deletion test/parser/parse.test.ts
Expand Up @@ -3,6 +3,7 @@ import {expect} from 'chai'

import {flags, parse} from '../../src/parser'
import {Interfaces} from '../../src'
const stripAnsi = require('strip-ansi')

describe('parse', () => {
it('--bool', async () => {
Expand Down Expand Up @@ -125,7 +126,7 @@ describe('parse', () => {
},
})
} catch (error) {
message = error.message
message = stripAnsi(error.message)
}
expect(message).to.equal(
'Missing required flag:\n --myflag MYFLAG flag description\nSee more help with --help',
Expand Down

0 comments on commit bfbd15c

Please sign in to comment.