Skip to content
This repository has been archived by the owner on Feb 1, 2022. It is now read-only.

Commit

Permalink
fix: add newline before context
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed Jan 28, 2018
1 parent 8fd5a20 commit 5ada0f5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ function bangify(msg: string, c: string): string {
for (let i = 0; i < lines.length; i++) {
const line = lines[i]
lines[i] = c + line.substr(2, line.length)
lines[i] = lines[i].trimRight()
}
return lines.join('\n')
}
Expand Down Expand Up @@ -60,7 +61,7 @@ export function getErrorMessage(err: any, opts: {stack?: boolean} = {}): string
// Unhandled error
if (err.message) message = err.message
if (context && !_.isEmpty(context)) {
message += '\n' + stripAnsi(indent(styledObject(err['cli-ux'].context), 4))
message += '\n\n' + stripAnsi(indent(styledObject(err['cli-ux'].context), 4))
}
message = message || inspect(err)

Expand Down
4 changes: 2 additions & 2 deletions test/errors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ describe('errors', () => {
cli.config.context = {foo: 'bar'}
cli.warn('foobar')
if (process.platform === 'win32') {
expect(output.stderr).to.equal(' ! Warning: foobar\n ! foo: bar\n')
expect(output.stderr).to.equal(' ! Warning: foobar\n !\n ! foo: bar\n')
} else {
expect(output.stderr).to.equal(' ▸ Warning: foobar\n ▸ foo: bar\n')
expect(output.stderr).to.equal(' ▸ Warning: foobar\n ▸\n ▸ foo: bar\n')
}
})

Expand Down

0 comments on commit 5ada0f5

Please sign in to comment.