UNPKG

t-comm

Version:

专业、稳定、纯粹的工具库

46 lines (43 loc) 1.21 kB
import { traverseFolder } from '../node/fs-util.mjs'; import 'fs'; import 'path'; import '../fs/fs.mjs'; import '../time/time.mjs'; /* eslint-disable @typescript-eslint/no-require-imports */ /** * 统计页面个数 * @example * statisticsPages('dist/build/mp-weixin/app.json') */ function statisticsPages(pagesJsonPath) { var path = require('path'); var pagesJson = require(path.resolve(process.cwd(), pagesJsonPath)); var _a = pagesJson.pages, pages = _a === void 0 ? [] : _a, _b = pagesJson.subPackages, subPackages = _b === void 0 ? [] : _b; var res = pages.length + subPackages.reduce(function (acc, item) { return acc + item.pages.length; }, 0); console.log('[statisticsPages] res: ', res); return res; } /** * 统计组件个数 * @example * statisticsComponent('dist/build/mp-weixin'); */ function statisticsComponent(dir) { var fs = require('fs'); var array = []; if (fs.existsSync(dir)) { traverseFolder(function (file) { if (file.endsWith('.wxml')) { array.push(file); } }, dir); } console.log('[statisticsComponent] array.length: ', array.length); return array.length; } export { statisticsComponent, statisticsPages };