mirror of
https://github.com/yldio/copilot.git
synced 2024-11-14 15:20:06 +02:00
35 lines
709 B
JavaScript
Executable File
35 lines
709 B
JavaScript
Executable File
#!/usr/bin/env node
|
|
|
|
const argv = require('yargs').argv;
|
|
const forEach = require('apr-for-each');
|
|
const main = require('apr-main');
|
|
const intercept = require('apr-intercept');
|
|
const execa = require('execa');
|
|
const path = require('path');
|
|
|
|
const ROOT = process.cwd();
|
|
|
|
if (!argv.cmd) {
|
|
throw new Error('Missing --cmd argument');
|
|
}
|
|
|
|
const run = () =>
|
|
forEach(argv._, async file => {
|
|
const cwd = path.dirname(path.join(ROOT, file));
|
|
|
|
const [err] = await intercept(
|
|
execa('yarn', ['run', argv.cmd], {
|
|
stdio: 'inherit',
|
|
cwd
|
|
})
|
|
);
|
|
|
|
if (err) {
|
|
console.error(`cmd: ${argv.cmd} | cwd: ${cwd}`);
|
|
console.error(err);
|
|
throw err;
|
|
}
|
|
});
|
|
|
|
main(run());
|