Created
May 23, 2018 11:15
-
-
Save hugomd/61bf21ea84172855f006484f7181b5e0 to your computer and use it in GitHub Desktop.
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
const main = async () => { | |
try { | |
// Initialise prompt with an empty message | |
prompt.start(); | |
prompt.message = ''; | |
// Turn prompt.get() into a promise | |
const get = util.promisify(prompt.get); | |
// Create a schema to validate user input | |
const usernameSchema = [ | |
{ | |
description: 'Enter your username', | |
name: 'username', | |
message: 'Username must be only letters, numbers, or dashes', | |
required: true, | |
}, | |
]; | |
// Ask the user for their username and assign it to a variable | |
const {username} = await get(usernameSchema); | |
+ await createUser(username); | |
} catch (err) { | |
console.log(`Failed with ${err}`); | |
process.exit(1); | |
} | |
}); | |
main(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment