Skip to content

fails silently when src/config/database.js is missing #7

@lightmare

Description

@lightmare

Any command, including exp-api -v, exits with 0 status without printing anything when it can't open src/config/database.js.

There are 4 issues:

  • exp-api -v shouldn't be looking for any files to begin with

  • utils.checkLangAndDB doesn't handle error from missing ./src:

    let files = fs.readdirSync('./src/');

  • utils.checkLangAndDB attempts to print error from missing ./src/config/database.js without importing chalk:

    try {
    if (config.lang === 'js') {
    db = await fs.readFile('./src/config/database.js');
    } else {
    db = await fs.readFile('./src/config/database.ts');
    }
    db = db.toString();
    } catch (error) {
    console.log(
    chalk.yellow(`
    Database config not detected in src/config.
    express-api-cli shall assume project default database config uses mongoose. Thank you.
    `)
    );
    }

  • all unhandled errors are swallowed:

    } catch (error) {}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions