mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
fix(cli): should exit process when lint failed
This commit is contained in:
parent
5cfa9ac808
commit
46a7aefc65
@ -22,28 +22,36 @@ function lintScript() {
|
|||||||
const formatted = formatter(report.results);
|
const formatted = formatter(report.results);
|
||||||
if (formatted) {
|
if (formatted) {
|
||||||
stepper.error('ESLint Failed', '\n' + formatter(report.results));
|
stepper.error('ESLint Failed', '\n' + formatter(report.results));
|
||||||
} else {
|
return false;
|
||||||
stepper.success('ESLint Passed');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stepper.success('ESLint Passed');
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function lintStyle() {
|
async function lintStyle(): Promise<boolean> {
|
||||||
stepper.start('Stylelint Start');
|
stepper.start('Stylelint Start');
|
||||||
|
|
||||||
stylelint({
|
return stylelint({
|
||||||
fix: true,
|
fix: true,
|
||||||
formatter: 'string',
|
formatter: 'string',
|
||||||
files: ['src/**/*.css', 'src/**/*.less', 'src/**/*.scss', 'src/**/*.vue']
|
files: ['src/**/*.css', 'src/**/*.less', 'src/**/*.scss', 'src/**/*.vue']
|
||||||
}).then(result => {
|
}).then(result => {
|
||||||
if (result.errored) {
|
if (result.errored) {
|
||||||
stepper.error('Stylelint Failed', '\n' + result.output);
|
stepper.error('Stylelint Failed', '\n' + result.output);
|
||||||
} else {
|
return false;
|
||||||
stepper.success('Stylelint Passed');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stepper.success('Stylelint Passed');
|
||||||
|
return true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function lint() {
|
export async function lint() {
|
||||||
lintScript();
|
const scriptPassed = lintScript();
|
||||||
lintStyle();
|
const stylePassed = await lintStyle();
|
||||||
|
|
||||||
|
if (!scriptPassed || !stylePassed) {
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user