-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.js
executable file
·41 lines (34 loc) · 1.08 KB
/
init.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
var fs = require('fs');
var readline = require('readline');
var rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
var config = new Object();
config.CompanyName = "MyCompany";
config.SiteTitle="My Employee Tracking";
config.DBHost="localhost";
config.DBUser="DBUserName";
config.DBPass="DBPassword";
config.DBName="MyDatabase";
config.DefaultUser="root";
config.DefaultPass="Roger";
config.DefaultEmail="[email protected]";
config.DefaultPicture="http://placekitten.com/320/320/";
var configfiletext = JSON.stringify(config, null, 2);
if(fs.existsSync("config.json")){
rl.question("A config file already exists. Do you want to create a new one? All data will be lost! [no]", (answer) =>{
if(answer.toLowerCase() != "yes") {
console.log("Config init canceled. Using existing config");
process.exit(0)
}
else {
console.log("Config file overwritten");
fs.writeFile("config.json", configfiletext, function(err){
if(err) console.log(err);
else console.log("Config File Successfully Created");
process.exit(0);
});
}
});
}