Skip to content

Commit 59e026f

Browse files
committed
I just wanna tell you how i'm feeling
1 parent 8fa6239 commit 59e026f

2 files changed

Lines changed: 29 additions & 18 deletions

File tree

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
{
1+
{
2+
23
"dependencies": {
34
"chalk": "^5.0.0",
45
"prompt-sync": "^4.2.0"

run.js

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,33 @@
1-
const prompt = require("prompt-sync")
2-
const chalk = require("chalk")
3-
const path = require('path');
4-
const warn = function(message, color){
5-
if (!color) color = red
6-
console.log(chalk[color](message))
7-
}
8-
1+
let prompt = require("prompt-sync")()
2+
let chalk = import("chalk")
3+
let path = require("path")
4+
let fs = require("fs")
5+
let log = console.log;
6+
let http = require("http")
97

10-
if (path.existsSync("/data")) { // or fs.existsSync
11-
warn("WARNING: Folder \"data\" will be erased and rebuilt if you proceed")
8+
if (fs.existsSync("data")) {
9+
console.log("WARNING: Folder \"data\" will be erased and rebuilt if you proceed")
1210
const answer = prompt("Would you like to proceed? (S/N)")
13-
if (String(answer).toUpperCase=="S"){
14-
//delete
15-
console.log("Done")
16-
} else if (String(answer).toUpperCase=="N"){
11+
if (answer.toUpperCase() =="S"){
12+
log("removing")
13+
fs.rmdirSync("data",{recursive: true})
14+
console.log("Done!")
15+
console.log("Now we can start the HTTP server lol")
16+
17+
} else if (answer.toUpperCase() =="N"){
1718
console.log("Goodbye!")
18-
exit(0)
19+
process.exit(0)
1920
}else{
20-
warn("Not a valid answer. Exiting...")
21-
exit(1)
21+
console.log("Not a valid answer. Exiting...")
22+
process.exit(1)
2223
}
2324
}
25+
26+
const requestListener = function (req, res) {
27+
log(req.url)
28+
29+
}
30+
31+
const server = http.createServer(requestListener);
32+
log("Server created. Starting...")
33+
server.listen(80);

0 commit comments

Comments
 (0)