diff --git a/index.js b/index.js index 25e38e5..c2a6ed0 100755 --- a/index.js +++ b/index.js @@ -22,7 +22,10 @@ const NODE_VERSION = process.versions.node.split('.').map(n => +n) let args = process.argv.slice(2) let mode = args.shift() || 'prod' -let clean = args.shift() !== '--no-clean' +let clean, verbose +args = args.join(' ') +clean = args.includes('--no-clean') // +verbose = args.includes('--verbose') // if (NODE_VERSION[0] < 16 || (NODE_VERSION[0] === 16 && NODE_VERSION[1] < 6)) { console.log(red('Error: 你当前的环境不满足 fite 构建工具的要求')) @@ -57,7 +60,7 @@ switch (mode) { if (clean && fs.isdir(dist)) { fs.rm(dist) } - compile(WORK_SPACE, dist, conf.default) + compile(WORK_SPACE, dist, conf.default, verbose) }) .catch(err => { console.log(err) diff --git a/lib/prod.js b/lib/prod.js index c239dd3..313a69d 100644 --- a/lib/prod.js +++ b/lib/prod.js @@ -8,7 +8,7 @@ function readFile(file) { return (file && fs.cat(file)?.toString()) || '' } -export default function compile(root = '', dist = '', conf = {}) { +export default function compile(root = '', dist = '', conf = {}, verbose) { // const SOURCE_DIR = join(root, 'src') const PUBLIC_DIR = join(root, 'public') @@ -82,7 +82,7 @@ export default function compile(root = '', dist = '', conf = {}) { continue } - page === null && console.log(' 解析 %s ...', it.name) + verbose && console.log(' 解析 %s ...', it.name) let pageDir = IS_MPA && currentPage ? `pages/${currentPage}` : '' @@ -148,11 +148,12 @@ export default function compile(root = '', dist = '', conf = {}) { if (fs.isfile(it)) { let name = it.slice(PUBLIC_DIR.length + 1) - console.log(' 复制 %s ...', name) + verbose && console.log(' 复制 %s ...', name) fs.cp(it, join(dist, name)) } }) } + console.log('') for (let currentPage in conf.pages) { let page = conf.pages[currentPage]