feat(cli): emit path of compile failed style

This commit is contained in:
陈嘉涵 2019-12-18 15:12:43 +08:00
parent 5ebb2fffd3
commit cee0bfa0e1

View File

@ -4,22 +4,28 @@ import { replaceExt } from '../common';
import { compileCss } from './compile-css'; import { compileCss } from './compile-css';
import { compileLess } from './compile-less'; import { compileLess } from './compile-less';
import { compileSass } from './compile-sass'; import { compileSass } from './compile-sass';
import { logger } from '../common/logger';
async function compileFile(filePath: string) { async function compileFile(filePath: string) {
const parsedPath = parse(filePath); const parsedPath = parse(filePath);
if (parsedPath.ext === '.less') { try {
const source = await compileLess(filePath); if (parsedPath.ext === '.less') {
return compileCss(source); const source = await compileLess(filePath);
} return await compileCss(source);
}
if (parsedPath.ext === '.scss') { if (parsedPath.ext === '.scss') {
const source = await compileSass(filePath); const source = await compileSass(filePath);
return compileCss(source); return await compileCss(source);
} }
const source = readFileSync(filePath, 'utf-8'); const source = readFileSync(filePath, 'utf-8');
return compileCss(source); return await compileCss(source);
} catch (err) {
logger.error('Compile style failed: ' + filePath);
throw err;
}
} }
export async function compileStyle(filePath: string) { export async function compileStyle(filePath: string) {