Build testing newcoind.cfg as needed.

This commit is contained in:
Arthur Britto
2012-09-15 15:45:33 -07:00
parent f45886cc6d
commit 6865e575cb
2 changed files with 29 additions and 2 deletions

3
.gitignore vendored
View File

@@ -20,3 +20,6 @@ newcoind
# Ignore locally installed node_modules
node_modules
# Ignore tmp directory.
tmp

View File

@@ -7,21 +7,45 @@
console.log("server.js>");
var config = require("./config.js");
var utils = require("./utils.js");
var fs = require("fs");
var path = require("path");
var util = require("util");
// var child = require("child");
var serverPath = function(name) {
return "tmp/server/" + name;
};
// Return a server's newcoind.cfg as string.
var serverConfig = function(name) {
var cfg = config.servers[name];
return Object.keys(cfg).map(function (o) {
return util.format("[%s]\n%s\n", o, cfg[o]);
}).join("");
};
var writeConfig = function(name, done) {
fs.writeFile(path.join(serverPath(name), "newcoind.cfg"), serverConfig(name), 'utf8', done);
};
var makeBase = function(name, done) {
var path = serverPath(name);
console.log("start> %s: %s", name, path);
// Remove the existing dir.
utils.resetPath(path, parseInt('0777', 8), done);
// Reset the server directory, build it if needed.
utils.resetPath(path, parseInt('0777', 8), function (e) {
if (e) {
throw e;
}
else {
writeConfig(name, done);
}
});
console.log("start< %s", name);
};