Can't trace errors while running commands in non-interactive shell
@dthree
Figured it out. .exec was intended to be programmatic, so it eats teh error and returns it in exec's callback.
.parse calls .exec, so it eats the error when invoked through .parse, but not otherwise.
#!/usr/bin/env node
var program = require('vorpal')();
var path = require('path');
var fs = require('fs');
var colors = require('colors');
var error = colors.bgRed.white.bold;
program.command('init [path]')
.description('Creates dummy config in current dir or [path]')
.action((args) => {
var path = args.path || '';
var configFile = path.join(process.cwd(), path, 'codecept.json');
this.log(path);
try {
fs.writeFileSync(configFile, '{}')
} catch (err) {
this.log(error(`File can't be created at ${configFile}`));
program.exit();
}
this.log(`Config created at ${configFile}`);
});
program.parse(process.argv);
Can't trace errors while running commands in non-interactive shell
@dthree