joyent-portal/scripts/prettier.js
Sérgio Ramos 8295bd6882 chore: initial lerna setup
this shall be a progressive process
2017-05-25 10:56:50 +01:00

27 lines
637 B
JavaScript
Executable File

#!/usr/bin/env node
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 = []) => {
const cp = execa('prettier', ['--write', '--single-quote'].concat(files));
cp.stdout.pipe(process.stdout);
cp.stderr.pipe(process.stderr);
return cp;
};
const all = async () => {
const files = await globby('{scripts,packages}/**/*.js', {
cwd: path.join(__dirname, '..')
});
return run(files.filter(pathname => !/node_modules/.test(pathname)));
};
main(argv._.length ? run(argv._) : all());