1 | const path = require('path')
|
2 |
|
3 | exports.name = 'eject-html'
|
4 |
|
5 | exports.cli = api => {
|
6 | api.cli
|
7 | .command('eject-html [out-file]', 'Eject the default HTML file')
|
8 | .option('--overwrite', 'Overwrite exiting file')
|
9 | .action(async (outFile = 'public/index.html', options) => {
|
10 | const fs = require('fs-extra')
|
11 | if (
|
12 | !options.overwrite &&
|
13 | (await fs.pathExists(api.resolveCwd(outFile)))
|
14 | ) {
|
15 | return api.logger.error(
|
16 | `${outFile} already existing, try --overwrite flag if you want to update it`
|
17 | )
|
18 | }
|
19 | await fs.copy(
|
20 | path.join(__dirname, '../webpack/default-template.html'),
|
21 | api.resolveCwd(outFile)
|
22 | )
|
23 | api.logger.done(`Ejected to ${outFile}`)
|
24 | })
|
25 | }
|