Fix '--home' option

This commit is contained in:
Mattias Erming 2014-10-14 22:53:26 +02:00
parent 1a620e1d54
commit e914ed50eb
4 changed files with 14 additions and 12 deletions

View File

@ -339,7 +339,7 @@ Client.prototype.save = function(force) {
}
var name = this.name;
var path = Helper.HOME + "/users/" + name + "/user.json";
var path = Helper.HOME + "/users/" + name + ".json";
var networks = _.map(
this.networks,

View File

@ -54,7 +54,7 @@ function add(manager, name, password) {
console.log("");
var salt = bcrypt.genSaltSync(8);
var hash = bcrypt.hashSync(password, salt);
var x = manager.addUser(
manager.addUser(
name,
hash
);

View File

@ -5,6 +5,8 @@ var mkdirp = require("mkdirp");
var Helper = require("../helper");
program.version(pkg.version, "-v, --version");
program.option("");
program.option(" --home <path>" , "home path");
require("./start");
require("./config");
@ -14,18 +16,20 @@ require("./remove");
require("./reset");
require("./edit");
program.parse(process.argv);
var argv = program.parseOptions(process.argv);
if (program.home) {
Helper.HOME = program.home;
} else {
var config = Helper.HOME + "/config.js";
if (!fs.existsSync(config)) {
mkdirp.sync(Helper.HOME);
fs.writeFileSync(config, fs.readFileSync(__dirname + "/../../defaults/config.js"));
}
}
var config = Helper.HOME + "/config.js";
if (!fs.existsSync(config)) {
mkdirp.sync(Helper.HOME);
fs.writeFileSync(config, fs.readFileSync(__dirname + "/../../defaults/config.js"));
console.log("Config created:" + config);
}
program.parse(argv.args);
if (!program.args.length) {
program.parse(process.argv.concat("start"));
}

View File

@ -5,8 +5,6 @@ var shout = require("../server");
var Helper = require("../helper");
program
.option("")
.option(" --home <path>" , "home path")
.option("-H, --host <ip>" , "host")
.option("-P, --port <port>" , "port")
.option("-B, --bind <ip>" , "bind")