增加容错处理,避免程序崩溃

master
yutent 2023-03-23 14:33:20 +08:00
parent c646875fd7
commit 135bced616
3 changed files with 12 additions and 8 deletions

View File

@ -47,14 +47,17 @@ export default function compile(root = '', isProd = false, es) {
{
let code = fs.cat(filePath).toString()
console.log('编译 %s ...', blue(file))
code = Es.transformSync(code, OPTIONS).code.replace(
/css`([\w\W]*?)`/g,
function (m, scss) {
try {
code = Es.transformSync(code, OPTIONS).code
} catch (err) {
console.log('compile scss: ', file)
console.error(err)
}
code = code.replace(/css`([\w\W]*?)`/g, function (m, scss) {
scss = compileScss(scss)
return `css\`${scss}\``
}
)
})
fs.echo(code, target)
}
break

View File

@ -24,5 +24,6 @@ export function compileScss(file, mini = true) {
} catch (err) {
console.log('compile scss: ', file)
console.error(err)
return ''
}
}

View File

@ -1,7 +1,7 @@
{
"name": "@bd/wcui-cli",
"type": "module",
"version": "1.1.0",
"version": "1.2.0",
"bin": {
"wcui-cli": "index.js"
},