Skip to content

Commit 92552bf

Browse files
committed
Connecting the readline-sync library and add cli.js
1 parent ebd39bd commit 92552bf

File tree

5 files changed

+26
-3
lines changed

5 files changed

+26
-3
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
/node_modules/
1+
/node_modules/
2+
.prettierrc.json

bin/brain-games.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
#!/usr/bin/env node
2+
import { getUserName } from '../src/cli.js';
3+
24
console.log('Welcome to the Brain Games!');
5+
getUserName();

package-lock.json

Lines changed: 11 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"brain-games": "bin/brain-games.js"
2323
},
2424
"dependencies": {
25-
"lodash": "^4.17.21"
25+
"lodash": "^4.17.21",
26+
"readline-sync": "^1.4.10"
2627
}
2728
}

src/cli.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import readlineSync from 'readline-sync';
2+
3+
const getUserName = () => {
4+
const userName = readlineSync.question('May I have your name? ');
5+
console.log(`Hello , ${userName} !`);
6+
};
7+
8+
export { getUserName };

0 commit comments

Comments
 (0)