Last active
March 19, 2019 22:32
-
-
Save misterdev/9e56242ea56dcf09f9bd5991a81a01dc to your computer and use it in GitHub Desktop.
6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = class WebpackGenerator extends Generator { | |
constructor(args, opts) { | |
/* ... */ | |
// => These are the defaults values | |
this.defaults = { | |
name: 'my-vue-project', | |
inFolder: 'src', | |
entry: 'main', | |
outFolder: 'dist', | |
publicFolder: 'public' | |
} | |
} | |
prompting() { | |
/* ... */ | |
]).then (answers => { | |
// => We store answers in a class attribute to make it available to other methods | |
this.answers = answers; | |
// => We replace every missing value with its default | |
this.answers.name = (answers.name !== '') ? answers.name.toLowerCase() : this.defaults.name; | |
this.answers.entry = (answers.entry !== '') ? answers.entry : this.defaults.entry; | |
this.answers.inFolder = (answers.inFolder !== '') ? answers.inFolder : this.defaults.inFolder; | |
this.answers.outFolder = (answers.outFolder !== '') ? answers.outFolder : this.defaults.outFolder; | |
this.answers.publicFolder = (answers.publicFolder !== '') ? answers.publicFolder : this.defaults.publicFolder; | |
// Yeah I know, this could be done better | |
}); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment