UNPKG

t-comm

Version:

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

51 lines (46 loc) 1.35 kB
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var node_fsUtil = require('../node/fs-util.js'); require('fs'); require('path'); require('../fs/fs.js'); require('../time/time.js'); /* 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)) { node_fsUtil.traverseFolder(function (file) { if (file.endsWith('.wxml')) { array.push(file); } }, dir); } console.log('[statisticsComponent] array.length: ', array.length); return array.length; } exports.statisticsComponent = statisticsComponent; exports.statisticsPages = statisticsPages;