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