2014-10-01 16:43:46 +00:00
|
|
|
var fs = require("fs");
|
|
|
|
var path = require("path");
|
2014-08-19 01:53:17 +00:00
|
|
|
var program = require("commander");
|
2014-10-01 16:43:46 +00:00
|
|
|
var mkdirp = require("mkdirp");
|
2014-08-19 01:53:17 +00:00
|
|
|
var child = require("child_process");
|
2014-10-01 16:43:46 +00:00
|
|
|
var Helper = require("../helper");
|
2014-08-19 01:53:17 +00:00
|
|
|
|
2014-10-01 16:43:46 +00:00
|
|
|
var CONFIG_PATH = process.env.SHOUT_CONFIG;
|
2014-10-01 21:15:17 +00:00
|
|
|
if (!CONFIG_PATH) {
|
2014-10-01 16:43:46 +00:00
|
|
|
CONFIG_PATH = Helper.resolveHomePath("config.js");
|
|
|
|
}
|
2014-10-01 21:15:17 +00:00
|
|
|
if (!fs.existsSync(CONFIG_PATH)) {
|
2014-10-01 16:43:46 +00:00
|
|
|
mkdirp.sync(Helper.getHomeDirectory());
|
|
|
|
var configFile = fs.readFileSync(path.resolve(__dirname, "..", "..", "config.js"));
|
|
|
|
fs.writeFileSync(CONFIG_PATH, configFile);
|
|
|
|
}
|
2014-09-09 20:06:26 +00:00
|
|
|
|
2014-08-19 01:53:17 +00:00
|
|
|
program
|
|
|
|
.command("config")
|
2014-09-09 20:06:26 +00:00
|
|
|
.description("Edit config: '" + CONFIG_PATH + "'")
|
2014-08-19 01:53:17 +00:00
|
|
|
.action(function() {
|
|
|
|
child.spawn(
|
2014-10-01 16:45:34 +00:00
|
|
|
"vi",
|
|
|
|
[CONFIG_PATH],
|
2014-08-19 01:53:17 +00:00
|
|
|
{stdio: "inherit"}
|
|
|
|
);
|
|
|
|
});
|