Skip to content

Commit

Permalink
set defaults for package-name and author
Browse files Browse the repository at this point in the history
  • Loading branch information
Jochen Probst committed Aug 8, 2019
1 parent fb9ba39 commit b726d0e
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions app/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
var Generator = require('yeoman-generator'),
updateNotifier = require('update-notifier'),
pkg = require('../package.json')
pkg = require('../package.json'),
{basename, resolve} = require('path')

updateNotifier({pkg}).notify()

Expand All @@ -9,17 +10,13 @@ module.exports = class extends Generator {
super(args, opts)
}
initializing(){
this.parentDir = __dirname
this.scope = basename(resolve(process.cwd(), '..'))
}
async prompting() {
this.answers = await this.prompt([{
type: 'input', name: 'scope',
message: 'Your scope (without @)',
},{
type : 'input', name : 'name',
message : 'Your project name',
default : ({scope}) => (scope ? `@${scope}/` : '')
+ this.appname.replace(/\s+/g, '-')
type: 'input', name: 'name',
message: 'Your project name (push enter to use default)',
default: () => `@${this.scope}/${this.appname.replace(/\s+/g, '-')}`
},{
type: 'input', name: 'description',
message: 'Package description',
Expand All @@ -28,6 +25,7 @@ module.exports = class extends Generator {
message: 'License',
},{
type: 'input', name: 'author',
default: () => this.scope,
message: 'Author',
},{
type: 'input', name: 'repository',
Expand Down

0 comments on commit b726d0e

Please sign in to comment.