build: throw error when compile style failed

This commit is contained in:
陈嘉涵 2019-09-30 09:53:09 +08:00
parent d7ef84d8cf
commit 48bd6d86d8
2 changed files with 18 additions and 9 deletions

View File

@ -16,15 +16,19 @@ const tasks = [
'cross-env NODE_ENV=production webpack -p --color --config build/webpack.pkg.js'
];
tasks.forEach(task => {
tasks.every(task => {
signale.start(task);
const interactive = new Signale({ interactive: true });
interactive.pending(task);
const result = shell.exec(`${task} --silent`);
if (result.code !== 0) {
interactive.error(task);
} else {
interactive.success(task);
return false;
}
interactive.success(task);
return true;
});

View File

@ -48,14 +48,19 @@ async function dest(output, paths) {
// compile component css
async function compile() {
let codes;
const paths = await glob(['./es/**/*.less', './lib/**/*.less'], { absolute: true });
try {
const paths = await glob(['./es/**/*.less', './lib/**/*.less'], { absolute: true });
codes = await Promise.all(paths.map(path => fs.readFile(path, 'utf-8')));
codes = await compileLess(codes, paths);
codes = await compilePostcss(codes, paths);
codes = await compileCsso(codes);
codes = await Promise.all(paths.map(path => fs.readFile(path, 'utf-8')));
codes = await compileLess(codes, paths);
codes = await compilePostcss(codes, paths);
codes = await compileCsso(codes);
await dest(codes, paths);
await dest(codes, paths);
} catch (err) {
console.log(err);
process.exit(1);
}
}
compile();