1
0
mirror of https://github.com/yldio/copilot.git synced 2024-11-14 15:20:06 +02:00
copilot/scripts/quality-docs
Sérgio Ramos 9b3874ea56 chore: format, lint, and test scripts based on staged files
For lint and test, it detects the packages that the staged files affect and only
runs the corresponding `lint` and `test` scripts.

For format, it will run prettier through the Added/Modified js files.
2017-05-26 10:20:00 +01:00

29 lines
689 B
JavaScript
Executable File

#!/usr/bin/env node
const forEach = require('apr-for-each');
const execa = require('execa');
const globby = require('globby');
const main = require('apr-main');
const argv = require('yargs').argv;
const path = require('path');
const run = async (files = []) =>
forEach(files, async file => {
const cp = execa('quality-docs', [file]);
cp.stdout.pipe(process.stdout);
cp.stderr.pipe(process.stderr);
return cp;
});
const all = async () => {
const files = await globby(['packages/**/*.md', './*.md'], {
cwd: path.join(__dirname, '..')
});
return run(files.filter(pathname => !/node_modules/.test(pathname)));
};
main(argv._.length ? run(argv._) : all());