Skip to content

Commit

Permalink
fix: show actual error when command is not run in an app folder
Browse files Browse the repository at this point in the history
  • Loading branch information
shazron committed Mar 15, 2022
1 parent ed46cbe commit b0346a0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
8 changes: 6 additions & 2 deletions src/BaseCommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,12 @@ class BaseCommand extends Command {
handleError (error) {
const errorMessages = ['no such file or directory', 'find configuration']
if (errorMessages.find(msg => error.message.includes(msg))) {
this.error(`Not a valid application root folder.
Please run 'aio app' commands from a folder generated by aio app init`)
const errorList = [
'Not a valid application root folder.',
'Please run \'aio app\' commands from a folder generated by aio app init',
error.message
]
this.error(errorList.join('\n'))
}
this.error(error.message)
}
Expand Down
9 changes: 7 additions & 2 deletions test/BaseCommand.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,13 @@ test('will change error message when aio app outside of the application root', a
const cmd = new TheCommand([])
cmd.error = jest.fn()
await cmd.catch(new Error('ENOENT: no such file or directory, open \'package.json\''))
expect(cmd.error).toHaveBeenCalledWith(`Not a valid application root folder.
Please run 'aio app' commands from a folder generated by aio app init`)

const errorList = [
'Not a valid application root folder.',
'Please run \'aio app\' commands from a folder generated by aio app init',
'ENOENT: no such file or directory, open \'package.json\''
]
expect(cmd.error).toHaveBeenCalledWith(errorList.join('\n'))
})

test('pjson', async () => {
Expand Down

0 comments on commit b0346a0

Please sign in to comment.