-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathrun-config.js
30 lines (26 loc) · 866 Bytes
/
run-config.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
var fse = require('fs-extra');
var fs = require('fs');
var path = require('path');
var byline = require('byline');
var mogodbConfigPath = './mongod.conf';
var stream = byline(fs.createReadStream(mogodbConfigPath));
var dbpath = "";
var logpath = "";
stream.on('data', function(line) {
var strs = line.toString().split('=');
if (strs[0] === 'dbpath') {
dbpath = strs[1];
}
if (strs[0] === 'logpath') {
logpath = path.dirname(strs[1]);
}
}).on('end', function () {
fse.ensureDir(dbpath, function (err) {
if(err) console.log(err); // => null
// dir has now been created, including the directory it is to be placed in
});
fse.ensureDir(logpath, function (err) {
if(err) console.log(err); // => null
// dir has now been created, including the directory it is to be placed in
});
});