UNPKG

@edwardxyt/gws-cli

Version:

这是一个web脚手架工具,用于生成基于webpack5,生成typescript+react17+mobx5+reactRouter6的应用。初衷是要解决多入口,多环境。单独编译单独运行的脚手架。做到小而美。拒绝锦上添花。

52 lines (45 loc) 1.52 kB
/** * 查看项目入口文件,适用于多项目多入口 * --DIR={All} 传空或all都会查询当前脚手架的所有入口列表 * * @example run tree --scripts-prepend-node-path=auto --DIR=All * @type {glob} */ const glob = require('glob'); const path = require('path'); const chalk = require('chalk'); const log = console.log; log(` ${chalk.white(`bin:tree`)} - ${chalk.red(`项目目录`)} `); let src = path.join(__dirname, '../', 'src'); let options = { nodir: true, }; let dirName = process.env.npm_config_DIR || '**'; if (dirName.toLowerCase() === 'all') { dirName = '**'; } // options is optional glob(`${src}/${dirName}/*/main.tsx`, options, function (er, files) { let total = 0; files.map((item, index) => { total = index; let dirArr = item.split('/'); let length = dirArr.length; let entry = `😊 ${dirArr[length - 3]}/${dirArr[length - 2]} 😊`; log(` ${item} - ${chalk.magenta(`${entry}`)}`); }); log(` ${chalk.white(`main.js 总数`)}${chalk.yellow(`${total + 1}`)}`); }); glob(`${src}/${dirName}/*/main.js`, options, function (er, files) { let total = 0; files.map((item, index) => { total = index; let dirArr = item.split('/'); let length = dirArr.length; let entry = `😊 ${dirArr[length - 3]}/${dirArr[length - 2]} 😊`; log(` ${item} - ${chalk.magenta(`${entry}`)}`); }); log(` ${chalk.white(`main.js 总数`)}${chalk.yellow(`${total + 1}`)}`); });