strapi/scripts/lint.js

36 lines
1.3 KiB
JavaScript
Raw Normal View History

2018-05-04 15:38:42 +02:00
const path = require('path');
const shell = require('shelljs');
const chalk = require('chalk');
const eslintErrorsFormatter = require('./eslintErrorsFormatter');
const frontCmd =
'node ../../node_modules/strapi-lint/node_modules/.bin/eslint --ignore-path .gitignore --ignore-pattern \'/admin/build/\' --config ../../node_modules/strapi-lint/lib/internals/eslint/front/.eslintrc.json admin';
const backCmd =
2018-05-04 17:02:27 +02:00
'node ../../node_modules/strapi-lint/node_modules/.bin/eslint --ignore-path .gitignore --ignore-pattern \'/admin\' --config ../../node_modules/strapi-lint/lib/internals/eslint/back/.eslintrc.json controllers config services bin lib';
2018-05-04 15:38:42 +02:00
const watcher = (label, pckgName, type = 'front') => {
shell.echo(label);
shell.cd(`packages/${pckgName}`);
2018-05-04 17:02:27 +02:00
2018-05-04 15:38:42 +02:00
const data = shell.exec(`${frontCmd} && ${backCmd}`, { silent: true });
shell.echo(chalk(eslintErrorsFormatter(data.stdout)));
shell.cd('../..');
if (data.code !== 0) {
process.exit(1);
}
shell.echo(`Lint tests passed in ${pckgName}`);
};
2018-05-04 17:02:27 +02:00
const packagesPath = path.resolve(process.env.PWD, 'packages');
shell.ls('* -d', packagesPath)
// TODO temporary just for eslint
2018-05-04 17:36:50 +02:00
.filter(package => package === 'strapi-generate')
2018-05-04 17:02:27 +02:00
// .filter(package => package !== 'README.md')
.forEach(package => {
watcher(`Testing ${package}`, package);
});
2018-05-04 17:31:21 +02:00
// process.exit(1);