-
-
Notifications
You must be signed in to change notification settings - Fork 240
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(cli): output to stdout not working with multiple output formatters #2044
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,9 +12,13 @@ jest.mock('../../services/linter'); | |
|
||
function run(command: string) { | ||
const parser = yargs.command(lintCommand).help(); | ||
return new Promise(done => { | ||
return new Promise((resolve, reject) => { | ||
parser.parse(command, (err: Error, argv: unknown, output: string) => { | ||
done(output); | ||
if (err) { | ||
reject(`${err.message}\n${output}`); | ||
} else { | ||
resolve(output); | ||
} | ||
}); | ||
}); | ||
} | ||
|
@@ -60,10 +64,9 @@ describe('lint', () => { | |
process.stdin.isTTY = isTTY; | ||
}); | ||
|
||
it('shows help when no document and no STDIN are present', async () => { | ||
it('shows help when no document and no STDIN are present', () => { | ||
process.stdin.isTTY = true; | ||
const output = await run('lint'); | ||
expect(output).toContain('documents Location of JSON/YAML documents'); | ||
return expect(run('lint')).rejects.toContain('documents Location of JSON/YAML documents'); | ||
}); | ||
|
||
describe('when STDIN is present', () => { | ||
|
@@ -204,7 +207,7 @@ describe('lint', () => { | |
}); | ||
|
||
it('shows help if unknown format is passed', () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps pop a test in here to verify something like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we have it already haha :D When I made the following change https://github.com/stoplightio/spectral/pull/2044/files#diff-5c1bab693e4315f93ddc3bc536502fe23b536bbed6214ca5a093571db6389f24R14-R21, the test started to fail. |
||
return expect(run('lint -f foo ./__fixtures__/empty-oas2-document.json')).resolves.toContain( | ||
return expect(run('lint -f foo ./__fixtures__/empty-oas2-document.json')).rejects.toContain( | ||
'documents Location of JSON/YAML documents. Can be either a file, a glob or', | ||
); | ||
}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this a regression with yargs or something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nope, it wasn't, I just updated it while I was at it.