Skip to content

Commit 248d396

Browse files
committed
codecrafters submit [skip ci]
1 parent 525864a commit 248d396

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

β€Žapp/main.js

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,25 @@ const readline = require("readline");
22

33
const commands = [];
44

5+
let terminal = true;
6+
57
const rl = readline.createInterface({
68
input: process.stdin,
79
output: process.stdout,
810
});
911

10-
rl.question("$ ", (answer) => {
11-
const command = answer.split(" ")[0];
12-
if (!commands.includes(command)) {
13-
console.log(`${command}: command not found`);
14-
}
15-
rl.close();
16-
});
12+
const promptUser = () => {
13+
rl.question("$ ", (answer) => {
14+
const command = answer.split(" ")[0];
15+
if (!commands.includes(command)) {
16+
console.log(`${command}: command not found`);
17+
}
18+
if (terminal) {
19+
promptUser();
20+
} else {
21+
rl.close();
22+
}
23+
});
24+
};
25+
26+
promptUser();

0 commit comments

Comments
 (0)