1 | const fs = require('fs')
|
2 | const path = require('path')
|
3 | const { ownDir } = require('./dir')
|
4 | const readProjectPkg = require('./readProjectPkg')
|
5 | const logger = require('@poi/logger')
|
6 |
|
7 | function 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 |
|
25 | module.exports = inferHTML
|