refactor: simplify package.js

This commit is contained in:
Clark Du 2018-08-31 20:48:33 +01:00
parent c20034b994
commit 783ef46cff
No known key found for this signature in database
GPG Key ID: D0E5986AF78B86D9

View File

@ -71,9 +71,9 @@ export default class Package extends EventEmitter {
this.packageObj.version = `${baseVersion}-${date}.${gitCommit}`
}
convertToEdge() {
convertTo(suffix) {
this.logger.info('Converting to edge package')
this.addNameSuffix('-edge')
this.addNameSuffix(`-${suffix}`)
this.generateVersion()
this.writePackage()
}
@ -88,7 +88,7 @@ export default class Package extends EventEmitter {
this.emit('build:before')
if (this.edge) {
this.convertToEdge()
this.convertTo('edge')
}
this.logger.info('Cleaning up')
@ -112,11 +112,7 @@ export default class Package extends EventEmitter {
}
copyFilesFrom(source, files) {
if (!files) {
files = source.packageObj.files || []
}
for (const file of files) {
for (const file of files || source.packageObj.files || []) {
const src = resolve(source.rootDir, file)
const dst = resolve(this.rootDir, file)
copySync(src, dst)