mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-06 21:10:38 +00:00
refactor: resolve packageJS one time
This commit is contained in:
parent
4ad1528b84
commit
fe2dd22c14
@ -19,7 +19,8 @@ export default class Package extends EventEmitter {
|
|||||||
|
|
||||||
this.rootDir = this.rootDir || process.cwd()
|
this.rootDir = this.rootDir || process.cwd()
|
||||||
this.distDir = this.resolvePath(this.distDir)
|
this.distDir = this.resolvePath(this.distDir)
|
||||||
this.packagePath = this.resolvePath('package.json')
|
this.packageJS = this.resolvePath('package.js')
|
||||||
|
this.packageJSON = this.resolvePath('package.json')
|
||||||
|
|
||||||
// Initialize
|
// Initialize
|
||||||
this.init()
|
this.init()
|
||||||
@ -41,13 +42,12 @@ export default class Package extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_readPackage() {
|
_readPackage() {
|
||||||
this.packageObj = readJSONSync(this.packagePath)
|
this.packageObj = readJSONSync(this.packageJSON)
|
||||||
}
|
}
|
||||||
|
|
||||||
_loadPackageJS() {
|
_loadPackageJS() {
|
||||||
const packageJS = this.resolvePath(this.rootDir, 'package.js')
|
if (existsSync(this.packageJS)) {
|
||||||
if (existsSync(packageJS)) {
|
let fn = require(this.packageJS)
|
||||||
let fn = require(packageJS)
|
|
||||||
fn = fn.default || fn
|
fn = fn.default || fn
|
||||||
if (typeof fn === 'function') {
|
if (typeof fn === 'function') {
|
||||||
fn(this, {
|
fn(this, {
|
||||||
@ -60,8 +60,8 @@ export default class Package extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
writePackage() {
|
writePackage() {
|
||||||
consola.debug('Writing', this.packagePath)
|
consola.debug('Writing', this.packageJSON)
|
||||||
writeFileSync(this.packagePath, JSON.stringify(this.packageObj, null, 2) + '\n')
|
writeFileSync(this.packageJSON, JSON.stringify(this.packageObj, null, 2) + '\n')
|
||||||
}
|
}
|
||||||
|
|
||||||
generateVersion() {
|
generateVersion() {
|
||||||
|
Loading…
Reference in New Issue
Block a user