UNPKG

658 BJavaScriptView Raw
1const fs = require('fs-extra')
2const { join } = require('path')
3const { getPageTplList } = require('./pageTpl')
4exports.isPageNameExists = function(pageName) {
5 const cwd = process.cwd()
6 return (
7 fs.pathExistsSync(join(cwd, `page/${pageName}.html`)) ||
8 fs.pathExistsSync(join(cwd, `src/${pageName}`))
9 )
10}
11/*
12检测本地或者远程是否存在模板
13 */
14exports.isPageTplExists = function(pageTpl, position) {
15 if (position === 'local') {
16 return fs.pathExistsSync(
17 join(process.cwd(), `template/${pageTpl}/index.html`)
18 )
19 } else {
20 const list = getPageTplList()
21 return list.includes(pageTpl)
22 }
23}