chore: upgrade prettier
This commit is contained in:
parent
b5605db095
commit
1416f5821b
@ -38,6 +38,7 @@
|
|||||||
"apr-intercept": "^1.0.4",
|
"apr-intercept": "^1.0.4",
|
||||||
"apr-main": "^1.0.7",
|
"apr-main": "^1.0.7",
|
||||||
"apr-map": "^1.0.5",
|
"apr-map": "^1.0.5",
|
||||||
|
"apr-parallel": "^1.0.5",
|
||||||
"apr-reduce": "^1.0.5",
|
"apr-reduce": "^1.0.5",
|
||||||
"apr-series": "^1.0.5",
|
"apr-series": "^1.0.5",
|
||||||
"apr-sort-by": "^1.0.5",
|
"apr-sort-by": "^1.0.5",
|
||||||
@ -73,7 +74,7 @@
|
|||||||
"lodash.isstring": "^4.0.1",
|
"lodash.isstring": "^4.0.1",
|
||||||
"lodash.uniq": "^4.5.0",
|
"lodash.uniq": "^4.5.0",
|
||||||
"lodash.uniqby": "^4.7.0",
|
"lodash.uniqby": "^4.7.0",
|
||||||
"prettier": "1.4.4",
|
"prettier": "1.5.3",
|
||||||
"quality-docs": "^3.3.0",
|
"quality-docs": "^3.3.0",
|
||||||
"read-pkg": "^2.0.0",
|
"read-pkg": "^2.0.0",
|
||||||
"redrun": "^5.9.15",
|
"redrun": "^5.9.15",
|
||||||
|
@ -8,6 +8,7 @@ const awaitify = require('apr-awaitify');
|
|||||||
const asyncFilter = require('apr-filter');
|
const asyncFilter = require('apr-filter');
|
||||||
const map = require('apr-map');
|
const map = require('apr-map');
|
||||||
const reduce = require('apr-reduce');
|
const reduce = require('apr-reduce');
|
||||||
|
const parallel = require('apr-parallel');
|
||||||
const execa = require('execa');
|
const execa = require('execa');
|
||||||
const globby = require('globby');
|
const globby = require('globby');
|
||||||
const main = require('apr-main');
|
const main = require('apr-main');
|
||||||
@ -29,30 +30,67 @@ const statuses = ['Added', 'Modified'];
|
|||||||
|
|
||||||
const filter = (files = []) =>
|
const filter = (files = []) =>
|
||||||
files
|
files
|
||||||
.filter(file => !/node_modules/.test(file))
|
.filter(file => !/node_modules|dist/.test(file))
|
||||||
.map(file => path.resolve(ROOT, file))
|
.map(file => path.resolve(ROOT, file))
|
||||||
.filter(file => !optOut.some(pkg => file.indexOf(pkg) === 0));
|
.filter(file => !optOut.some(pkg => file.indexOf(pkg) === 0));
|
||||||
|
|
||||||
const run = async (files = []) => {
|
const run = async (files = []) => {
|
||||||
const filteredFiles = filter(files);
|
const filteredFiles = filter(files);
|
||||||
|
|
||||||
if (!filteredFiles.length) {
|
const _files = filteredFiles.reduce(
|
||||||
return;
|
(files, file) => {
|
||||||
|
const ext = path.extname(file).replace(/^./, '') || 'js';
|
||||||
|
return Object.assign(files, {
|
||||||
|
[ext]: files[ext].concat(file)
|
||||||
|
});
|
||||||
|
},
|
||||||
|
{
|
||||||
|
js: [],
|
||||||
|
gql: [],
|
||||||
|
json: []
|
||||||
}
|
}
|
||||||
|
);
|
||||||
|
|
||||||
return execa(
|
return parallel({
|
||||||
|
js: () =>
|
||||||
|
_files.js.length
|
||||||
|
? execa(
|
||||||
'prettier',
|
'prettier',
|
||||||
['--write', '--single-quote'].concat(filteredFiles),
|
['--write', '--single-quote', '--parser=babylon'].concat(_files.js),
|
||||||
{
|
{
|
||||||
stdio: 'inherit'
|
stdio: 'inherit'
|
||||||
}
|
}
|
||||||
);
|
)
|
||||||
|
: null,
|
||||||
|
gql: () =>
|
||||||
|
_files.gql.length
|
||||||
|
? execa(
|
||||||
|
'prettier',
|
||||||
|
['--write', '--single-quote', '--parser=graphql'].concat(
|
||||||
|
_files.gql
|
||||||
|
),
|
||||||
|
{
|
||||||
|
stdio: 'inherit'
|
||||||
|
}
|
||||||
|
)
|
||||||
|
: null,
|
||||||
|
json: () =>
|
||||||
|
_files.json.length
|
||||||
|
? execa(
|
||||||
|
'prettier',
|
||||||
|
['--write', '--single-quote', '--parser=json'].concat(_files.json),
|
||||||
|
{
|
||||||
|
stdio: 'inherit'
|
||||||
|
}
|
||||||
|
)
|
||||||
|
: null
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const add = async filename => execa('git', ['add', filename]);
|
const add = async filename => execa('git', ['add', filename]);
|
||||||
|
|
||||||
const all = async () => {
|
const all = async () => {
|
||||||
const files = await globby(['packages/**/*.js', 'scripts/*'], {
|
const files = await globby(['packages/**/*.{js,gql,json}', 'scripts/*'], {
|
||||||
cwd: path.join(__dirname, '..')
|
cwd: path.join(__dirname, '..')
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -67,7 +105,7 @@ const getUnstaged = async () => {
|
|||||||
const staged = async () => {
|
const staged = async () => {
|
||||||
const unstaged = (await getUnstaged())
|
const unstaged = (await getUnstaged())
|
||||||
.map(file => path.resolve(ROOT, file))
|
.map(file => path.resolve(ROOT, file))
|
||||||
.filter(file => /\.js$/.test(file) || file.indexOf(SCRIPTS) === 0);
|
.filter(file => /\.js|gql|json$/.test(file) || file.indexOf(SCRIPTS) === 0);
|
||||||
|
|
||||||
const files = (await getStaged())
|
const files = (await getStaged())
|
||||||
.filter(({ status }) => statuses.indexOf(status) >= 0)
|
.filter(({ status }) => statuses.indexOf(status) >= 0)
|
||||||
@ -76,7 +114,8 @@ const staged = async () => {
|
|||||||
)
|
)
|
||||||
.filter(
|
.filter(
|
||||||
file =>
|
file =>
|
||||||
/\.js$/.test(file.filename) || file.filename.indexOf(SCRIPTS) === 0
|
/\.js|gql|json$/.test(file.filename) ||
|
||||||
|
file.filename.indexOf(SCRIPTS) === 0
|
||||||
);
|
);
|
||||||
|
|
||||||
const existing = await asyncFilter(
|
const existing = await asyncFilter(
|
||||||
|
Loading…
Reference in New Issue
Block a user