Skip to content

Commit

Permalink
fix: not all missing files errors are because of an invalid root fold…
Browse files Browse the repository at this point in the history
…er (#755)
  • Loading branch information
MichaelGoberling committed Dec 18, 2023
1 parent 1f35c49 commit 2e4115c
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 18 deletions.
15 changes: 1 addition & 14 deletions src/BaseCommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,7 @@ class BaseCommand extends Command {
async catch (error) {
const { flags } = await this.parse(this.prototype)
aioLogger.error(error) // debug log
this.handleError(error, flags.verbose)
}

handleError (error, verbose) {
const errorMessages = ['no such file or directory', 'find configuration']
if (errorMessages.find(msg => error.message.includes(msg))) {
const errorList = [
'Not a valid application root folder.',
'Please run \'aio app\' commands from a folder generated by aio app init',
verbose ? error.stack : error.message
]
this.error(errorList.join('\n'))
}
this.error(error.message)
this.error(flags.verbose ? error.stack : error.message)
}

async init () {
Expand Down
4 changes: 0 additions & 4 deletions test/BaseCommand.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,6 @@ test('will change error message when aio app outside of the application root', a
await cmd.catch(new Error('ENOENT: no such file or directory, open \'package.json\''))

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'))
Expand All @@ -272,8 +270,6 @@ test('will change error message when aio app outside of the application root (--
await cmd.catch(new Error('ENOENT: no such file or directory, open \'package.json\''))

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

0 comments on commit 2e4115c

Please sign in to comment.