-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: dublicate getProjectFolderName method
- Loading branch information
Showing
7 changed files
with
136 additions
and
208 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
const inquirer = require('inquirer'); | ||
|
||
const stringUtils = require('@src/utils/string-utils'); | ||
|
||
module.exports = { | ||
getProjectFolderName | ||
}; | ||
|
||
/** | ||
* To get user's input project folder name | ||
* @param {string} defaultName a default project name | ||
* @param {callback} callback { error, response } | ||
*/ | ||
function getProjectFolderName(defaultName, callback) { | ||
inquirer.prompt([{ | ||
message: 'Please type in your folder name for the skill project (alphanumeric): ', | ||
type: 'input', | ||
default: defaultName, | ||
name: 'projectFolderName', | ||
validate: (input) => { | ||
if (!input || stringUtils.filterNonAlphanumeric(input) === '') { | ||
return 'Project folder name should consist of alphanumeric character(s) plus "-" only.'; | ||
} | ||
return true; | ||
} | ||
}]).then((answer) => { | ||
callback(null, stringUtils.filterNonAlphanumeric(answer.projectFolderName)); | ||
}).catch((error) => { | ||
callback(error); | ||
}); | ||
} |
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.