Skip to content

Commit

Permalink
fix: remove fromScratch
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed Feb 1, 2018
1 parent f5a3197 commit 65d35c5
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions src/generators/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ class App extends Generator {
type: 'single' | 'multi' | 'plugin' | 'base'
path: string
pjson: any
fromScratch!: boolean
githubUser: string | undefined
answers!: {
name: string
Expand Down Expand Up @@ -114,7 +113,6 @@ class App extends Generator {
},
options: this.options,
}
this.fromScratch = Object.keys(this.pjson.dependencies).length === 0
if (this.options.defaults) {
this.answers = defaults
} else {
Expand Down Expand Up @@ -180,9 +178,9 @@ class App extends Generator {
name: 'options',
message: 'components to include',
choices: [
{name: 'mocha', checked: this.fromScratch ? false : !!this.pjson.devDependencies.mocha},
{name: 'typescript', checked: this.fromScratch ? false : !!this.pjson.devDependencies.typescript},
{name: 'semantic-release', checked: this.fromScratch ? false : !!this.fs.exists('.commitlintrc.js')},
{name: 'mocha', checked: !!this.pjson.devDependencies.mocha},
{name: 'typescript', checked: !!this.pjson.devDependencies.typescript},
{name: 'semantic-release', checked: !!this.fs.exists('.commitlintrc.js')},
],
filter: ((arr: string[]) => _.keyBy(arr)) as any,
},
Expand All @@ -192,7 +190,6 @@ class App extends Generator {
message: 'npm files to pack',
default: (answers: any) => answers.options.typescript ? '/lib' : '/src',
filter: stringToArray as any,
when: this.fromScratch,
},
]) as any
}
Expand Down Expand Up @@ -426,15 +423,13 @@ class App extends Generator {
}

private _writeBase() {
if (!this.fromScratch) return
this.fs.copyTpl(this.templatePath(`base/src/index.${this._ext}`), this.destinationPath(`src/index.${this._ext}`), this)
if (this.mocha) {
this.fs.copyTpl(this.templatePath(`base/test/index.test.${this._ext}`), this.destinationPath(`test/index.test.${this._ext}`), this)
}
}

private _writePlugin() {
if (!this.fromScratch) return
let bin = this.pjson.anycli.bin || this.pjson.anycli.dirname || this.pjson.name
if (bin.includes('/')) bin = bin.split('/').pop()
const cmd = `${bin} hello`
Expand All @@ -451,7 +446,6 @@ class App extends Generator {
}

private _writeSingle() {
if (!this.fromScratch) return
let bin = this.pjson.anycli.bin || this.pjson.anycli.dirname || this.pjson.name
if (bin.includes('/')) bin = bin.split('/').pop()
const opts = {...this as any, _, bin, cmd: bin, name: this.pjson.name}
Expand All @@ -464,7 +458,6 @@ class App extends Generator {
}

private _writeMulti() {
if (!this.fromScratch) return
this._writePlugin()
this.fs.copyTpl(this.templatePath('bin/run'), this.destinationPath('bin/run'), this)
this.fs.copyTpl(this.templatePath('bin/run.cmd'), this.destinationPath('bin/run.cmd'), this)
Expand Down

0 comments on commit 65d35c5

Please sign in to comment.