UNPKG

659 BJavaScriptView Raw
1const fs = require('fs')
2const path = require('path')
3const { ownDir } = require('./dir')
4const readProjectPkg = require('./readProjectPkg')
5const logger = require('@poi/logger')
6
7function inferHTML(options = {}) {
8 const pkg = readProjectPkg()
9 const result = {
10 pkg,
11 title: pkg.productName || pkg.name || 'Poi App',
12 description: pkg.description,
13 template: ownDir('lib/index.ejs')
14 }
15
16 const templatePath = path.resolve(options.cwd || process.cwd(), 'index.ejs')
17 if (fs.existsSync(templatePath)) {
18 logger.debug(`HTML template file`, templatePath)
19 result.template = templatePath
20 }
21
22 return result
23}
24
25module.exports = inferHTML