UNPKG

@fuse-oo/cli

Version:

fuse内部脚手架工具

25 lines (21 loc) 773 B
// 写入文件,安装依赖 const fs = require('fs-extra') const chalk = require('chalk') const path = require('path') const nunjucks = require('nunjucks') const { log, error, logWithSpinner, stopSpinner, } = require('./common') module.exports = async function writeHtmlIndex (context, cliOptions) { logWithSpinner(`${chalk.cyan('[3/3]')} 🔨 修改${chalk.yellow(`index.html`)}`) // index.html 添加第三方库的引入 const tempPath = path.resolve(__dirname, '../../temp/html/index.html') const libTemp = await fs.readFile(tempPath) const libContent = nunjucks.renderString(libTemp.toString(), cliOptions) const _context = `${context}` await fs.writeFile(path.resolve(_context, `./index.html`), libContent, {flag: 'w'}) stopSpinner() }