diff --git a/lib/create.js b/lib/create.js index 5547f03..9a7cf55 100644 --- a/lib/create.js +++ b/lib/create.js @@ -13,6 +13,7 @@ async function create() { let options = await promptCreateOptions(); createProject(options.projectName, options.projectPath, options); + saveDefaults(options); } async function createProject(projectName, projectPath, options) { @@ -65,11 +66,18 @@ async function createProject(projectName, projectPath, options) { console.log(`✨ ${projectName} created at ${fullProjectPath}`); } +function saveDefaults(options) { + if (options.author) { + config.set('author', options.author); + } +} + async function promptCreateOptions() { options = {}; options.projectName = await promptProjectName(); options.projectPath = await promptProjectPath(); + options.author = await promptAuthor(); if (await promptShouldInitGitRepository()) { options.shouldInitGitRepository = true; @@ -128,6 +136,19 @@ async function promptProjectPath() { }); } +async function promptAuthor() { + return await inquirer.prompt([ + { + type: 'input', + name: 'author', + message: 'Author?', + ...(config.has('author') && { default: config.get('author') }), + } + ]).then((answers) => { + return answers.author; + }); +} + async function promptShouldInitGitRepository() { return await inquirer.prompt([ { @@ -316,6 +337,7 @@ function addPackageFile(projectPath, options) { name: options.projectName, version: '1.0.0', private: false, + author: options.author, license: 'MIT', ...(options.shouldInitGitRepository && options.shouldAddRemote && { repository: {