@interaktiv/dia-scripts
Version:
CLI toolbox with common scripts for most sort of projects at DIA
38 lines (31 loc) • 927 B
JavaScript
;
const exit = require('exit');
const spawn = require('cross-spawn');
const yargsParser = require('yargs-parser');
const {
resolveBin,
ifSfdxProject,
getConcurrentlyArgs,
resolveSelf
} = require('../../utils');
const rawArgv = process.argv.slice(2);
const argv = yargsParser(rawArgv);
const {
_: testScripts
} = argv;
const useDefaultScripts = testScripts.length === 0;
const diaScripts = resolveSelf();
if (useDefaultScripts) {
const scripts = {
'test:apex': ifSfdxProject(`${diaScripts} test/apex ${rawArgv.join(' ')}`),
'test:javascript': `${diaScripts} test/javascript ${[...rawArgv, '--no-watch'].join(' ')}`
};
const result = spawn.sync(resolveBin('concurrently'), getConcurrentlyArgs(scripts), {
stdio: 'inherit'
});
exit(result.status);
} else {
const script = testScripts.shift();
process.argv = process.argv.filter(a => a !== script);
require(`./${script}`);
}