forked from jserme/123.jser.us
-
Notifications
You must be signed in to change notification settings - Fork 0
/
add.js
executable file
·43 lines (33 loc) · 871 Bytes
/
add.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
41
42
43
#!/usr/bin/env node
var readline = require('readline');
var fs = require('fs');
var path = require('path');
var keyArry = ['name', 'description', 'url', 'tags'];
var rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
var i = 0;
var rst = {};
var DATAPATH = './data';
function init() {
rl.question("site " + keyArry[i] + ' is:', function(answer) {
rst[keyArry[i]] = answer;
i++;
if (i == keyArry.length) {
fs.writeFile(path.join(DATAPATH, rst.name), JSON.stringify({
description: rst.description,
tags: rst.tags,
url: rst.url
}), function(err) {
if (err) {
throw err;
}
});
i = 0;
rst = {};
}
init();
});
}
init();