function addStartupFile()

in apps/mountebank-mock/mountebank-source/src/cli/cli.js [367:388]


function addStartupFile (args) {
    if (typeof args.rcfile !== 'string' || args.rcfile === '') {
        return;
    }
    if (!fs.existsSync(args.rcfile)) {
        console.error(`Cannot find rcfile ${args.rcfile}`);
        return;
    }
    try {
        const rc = JSON.parse(fs.readFileSync(args.rcfile));

        // CLI options take priority over anything in the rcfile.
        Object.keys(rc).forEach(key => {
            if (!argIsPassedOnCLI(key)) {
                args[key] = rc[key];
            }
        });
    }
    catch (ex) {
        console.error(`Cannot parse rcfile ${args.rcfile}: ${ex}`);
    }
}