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

Commit 5ada0f5

Browse files
committed
fix: add newline before context
1 parent 8fd5a20 commit 5ada0f5

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/errors.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ function bangify(msg: string, c: string): string {
3232
for (let i = 0; i < lines.length; i++) {
3333
const line = lines[i]
3434
lines[i] = c + line.substr(2, line.length)
35+
lines[i] = lines[i].trimRight()
3536
}
3637
return lines.join('\n')
3738
}
@@ -60,7 +61,7 @@ export function getErrorMessage(err: any, opts: {stack?: boolean} = {}): string
6061
// Unhandled error
6162
if (err.message) message = err.message
6263
if (context && !_.isEmpty(context)) {
63-
message += '\n' + stripAnsi(indent(styledObject(err['cli-ux'].context), 4))
64+
message += '\n\n' + stripAnsi(indent(styledObject(err['cli-ux'].context), 4))
6465
}
6566
message = message || inspect(err)
6667

test/errors.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ describe('errors', () => {
2222
cli.config.context = {foo: 'bar'}
2323
cli.warn('foobar')
2424
if (process.platform === 'win32') {
25-
expect(output.stderr).to.equal(' ! Warning: foobar\n ! foo: bar\n')
25+
expect(output.stderr).to.equal(' ! Warning: foobar\n !\n ! foo: bar\n')
2626
} else {
27-
expect(output.stderr).to.equal(' ▸ Warning: foobar\n ▸ foo: bar\n')
27+
expect(output.stderr).to.equal(' ▸ Warning: foobar\n ▸\n ▸ foo: bar\n')
2828
}
2929
})
3030

0 commit comments

Comments
 (0)