|
3 | 3 | const fs = require('fs')
|
4 | 4 | const cp = require('cp-file').sync
|
5 | 5 | const chalk = require('chalk')
|
6 |
| -const util = require('../util') |
7 |
| - |
8 |
| -const {cwd, exists, pwd, read, resolve} = util |
| 6 | +const {cwd, exists, pkg, pwd, read, resolve} = require('../util') |
9 | 7 |
|
10 | 8 | const replace = function (file, tpl, replace) {
|
11 | 9 | fs.writeFileSync(file, read(file).replace(tpl, replace), 'utf-8')
|
12 | 10 | }
|
13 | 11 |
|
14 |
| -const PKG = util.pkg() |
15 |
| - |
16 | 12 | // eslint-disable-next-line
|
17 | 13 | module.exports = function (path = '', local, theme) {
|
18 | 14 | const msg =
|
@@ -48,21 +44,21 @@ module.exports = function (path = '', local, theme) {
|
48 | 44 |
|
49 | 45 | replace(target(filename), 'vue.css', `${theme}.css`)
|
50 | 46 |
|
51 |
| - if (PKG.name) { |
| 47 | + if (pkg.name) { |
52 | 48 | replace(
|
53 | 49 | target(filename),
|
54 | 50 | 'Document',
|
55 |
| - PKG.name + (PKG.description ? ' - ' + PKG.description : '') |
| 51 | + pkg.name + (pkg.description ? ' - ' + pkg.description : '') |
56 | 52 | )
|
57 |
| - replace(target(filename), 'name: \'\',', `name: '${PKG.name}',`) |
| 53 | + replace(target(filename), 'name: \'\',', `name: '${pkg.name}',`) |
58 | 54 | }
|
59 | 55 |
|
60 |
| - if (PKG.description) { |
61 |
| - replace(target(filename), 'Description', PKG.description) |
| 56 | + if (pkg.description) { |
| 57 | + replace(target(filename), 'Description', pkg.description) |
62 | 58 | }
|
63 | 59 |
|
64 |
| - if (PKG.repository) { |
65 |
| - const repo = (PKG.repository.url || PKG.repository) |
| 60 | + if (pkg.repository) { |
| 61 | + const repo = (pkg.repository.url || pkg.repository) |
66 | 62 | .replace(/\.git$/g, '')
|
67 | 63 | .replace(/^git\+/g, '')
|
68 | 64 | replace(target(filename), 'repo: \'\'', `repo: '${repo}'`)
|
|
0 commit comments