From 73ff200b873428b6227781197909d98be120e4eb Mon Sep 17 00:00:00 2001 From: yutent Date: Mon, 29 May 2023 15:45:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=BC=96=E8=AF=91=E5=8F=82?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.js | 7 +++++-- lib/prod.js | 7 ++++--- 2 files changed, 9 insertions(+), 5 deletions(-) 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]