-
Notifications
You must be signed in to change notification settings - Fork 164
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
chore: warns the user appropriately for non-existent files #182
Conversation
start command
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.
Would you mind applying the suggestion and adding a unit test?
e244149
to
497c5fe
Compare
You can mock |
@mcollina It seems that 4 test cases are failing. How should be the following error message be refactored 🤔 fastify-cli/test/start.test.js Line 151 in f8ca00c
|
You need to change Line 74 in f8ca00c
stop if the error is not provided. Then, you need to change your PR so that the message is passed as a second argument instead.
|
e52c701
to
272e3e6
Compare
@xtx1130 Can you draw a better picture regarding the failing tests and how should it be fixed up 🤔 |
@jamesgeorge007 I have got wrong, you need to accept mcollina's suggest, add another param to ensure stop support warning, such as : function stop (error, warn) {
if (error) {
console.log(error)
process.exit(1)
}
if (warn) {
console.log(warn)
}
process.exit()
} And you need to change: return module.exports.stop(`${opts._[0]} doesn't exist within ${process.cwd()}`) to return module.exports.stop('', `${opts._[0]} doesn't exist within ${process.cwd()}`) The test case should change to: test('should throw on file not found', t => {
t.plan(1)
const oldStop = start.stop
t.tearDown(() => { start.stop = oldStop })
start.stop = function (err, warn) {
// test case changes
t.ok(/.*not-found doesn't exist within/.test(warn), warn)
}
const argv = [ '-p', getPort(), './data/not-found.js' ]
start.start(argv)
}) |
d59b919
to
252da38
Compare
@jamesgeorge007 There still have some test cases you need to deal with. You can run |
252da38
to
7948c86
Compare
@xtx1130 I'm not able to figure out what's going wrong with the currently failing tests. Any sort of help is appreciated 👏 |
7948c86
to
808bcfc
Compare
cc @xtx1130 |
remove eslint disable comment
52c4272
to
06d9cf8
Compare
cc @mcollina |
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.
LGTM
Fixes #181
Shows up a warning rather than throwing the error.