Merge pull request #390 from hogofwar/master
Supersede mkdirp with fs-extra
This commit is contained in:
commit
ee0ebdc759
@ -49,7 +49,6 @@
|
|||||||
"fs-extra": "0.30.0",
|
"fs-extra": "0.30.0",
|
||||||
"irc-framework": "2.0.0",
|
"irc-framework": "2.0.0",
|
||||||
"lodash": "4.11.2",
|
"lodash": "4.11.2",
|
||||||
"mkdirp": "0.5.1",
|
|
||||||
"moment": "2.13.0",
|
"moment": "2.13.0",
|
||||||
"read": "1.0.7",
|
"read": "1.0.7",
|
||||||
"request": "2.72.0",
|
"request": "2.72.0",
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
var _ = require("lodash");
|
var _ = require("lodash");
|
||||||
var fs = require("fs");
|
var fs = require("fs");
|
||||||
var Client = require("./client");
|
var Client = require("./client");
|
||||||
var mkdirp = require("mkdirp");
|
|
||||||
var Helper = require("./helper");
|
var Helper = require("./helper");
|
||||||
var oidentd = require("./oidentd");
|
var oidentd = require("./oidentd");
|
||||||
|
|
||||||
@ -52,7 +51,6 @@ ClientManager.prototype.loadUser = function(name) {
|
|||||||
|
|
||||||
ClientManager.prototype.getUsers = function() {
|
ClientManager.prototype.getUsers = function() {
|
||||||
var users = [];
|
var users = [];
|
||||||
mkdirp.sync(Helper.USERS_PATH);
|
|
||||||
try {
|
try {
|
||||||
var files = fs.readdirSync(Helper.USERS_PATH);
|
var files = fs.readdirSync(Helper.USERS_PATH);
|
||||||
files.forEach(function(file) {
|
files.forEach(function(file) {
|
||||||
@ -73,7 +71,6 @@ ClientManager.prototype.addUser = function(name, password) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
mkdirp.sync(Helper.USERS_PATH);
|
|
||||||
|
|
||||||
if (require("path").basename(name) !== name) {
|
if (require("path").basename(name) !== name) {
|
||||||
throw new Error(name + " is an invalid username.");
|
throw new Error(name + " is an invalid username.");
|
||||||
|
@ -1,19 +1,12 @@
|
|||||||
var ClientManager = new require("../clientManager");
|
var ClientManager = new require("../clientManager");
|
||||||
var bcrypt = require("bcrypt-nodejs");
|
var bcrypt = require("bcrypt-nodejs");
|
||||||
var program = require("commander");
|
var program = require("commander");
|
||||||
var mkdirp = require("mkdirp");
|
|
||||||
var Helper = require("../helper");
|
var Helper = require("../helper");
|
||||||
|
|
||||||
program
|
program
|
||||||
.command("add <name>")
|
.command("add <name>")
|
||||||
.description("Add a new user")
|
.description("Add a new user")
|
||||||
.action(function(name/* , password */) {
|
.action(function(name/* , password */) {
|
||||||
try {
|
|
||||||
mkdirp.sync(Helper.USERS_PATH);
|
|
||||||
} catch (e) {
|
|
||||||
log.error("Could not create", Helper.USERS_PATH);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var manager = new ClientManager();
|
var manager = new ClientManager();
|
||||||
var users = manager.getUsers();
|
var users = manager.getUsers();
|
||||||
if (users.indexOf(name) !== -1) {
|
if (users.indexOf(name) !== -1) {
|
||||||
|
@ -3,7 +3,7 @@ global.log = require("../log.js");
|
|||||||
var program = require("commander");
|
var program = require("commander");
|
||||||
var pkg = require("../../package.json");
|
var pkg = require("../../package.json");
|
||||||
var fs = require("fs");
|
var fs = require("fs");
|
||||||
var mkdirp = require("mkdirp");
|
var fsextra = require("fs-extra");
|
||||||
var path = require("path");
|
var path = require("path");
|
||||||
var Helper = require("../helper");
|
var Helper = require("../helper");
|
||||||
|
|
||||||
@ -16,20 +16,20 @@ var argv = program.parseOptions(process.argv);
|
|||||||
Helper.setHome(program.home);
|
Helper.setHome(program.home);
|
||||||
|
|
||||||
if (!fs.existsSync(Helper.CONFIG_PATH)) {
|
if (!fs.existsSync(Helper.CONFIG_PATH)) {
|
||||||
mkdirp.sync(Helper.HOME, {mode: "0700"});
|
fsextra.ensureDirSync(Helper.HOME);
|
||||||
fs.writeFileSync(
|
fs.chmodSync(Helper.HOME, "0700");
|
||||||
Helper.CONFIG_PATH,
|
fsextra.copySync(path.resolve(path.join(
|
||||||
fs.readFileSync(path.resolve(path.join(
|
__dirname,
|
||||||
__dirname,
|
"..",
|
||||||
"..",
|
"..",
|
||||||
"..",
|
"defaults",
|
||||||
"defaults",
|
"config.js"
|
||||||
"config.js"
|
)), Helper.CONFIG_PATH);
|
||||||
)))
|
|
||||||
);
|
|
||||||
log.info("Config created:", Helper.CONFIG_PATH);
|
log.info("Config created:", Helper.CONFIG_PATH);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fsextra.ensureDirSync(Helper.USERS_PATH);
|
||||||
|
|
||||||
require("./start");
|
require("./start");
|
||||||
require("./config");
|
require("./config");
|
||||||
require("./list");
|
require("./list");
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
var fs = require("fs");
|
var fs = require("fs");
|
||||||
var mkdirp = require("mkdirp");
|
var fsextra = require("fs-extra");
|
||||||
var moment = require("moment");
|
var moment = require("moment");
|
||||||
var Helper = require("./helper");
|
var Helper = require("./helper");
|
||||||
|
|
||||||
module.exports.write = function(user, network, chan, msg) {
|
module.exports.write = function(user, network, chan, msg) {
|
||||||
try {
|
try {
|
||||||
var path = Helper.getUserLogsPath(user, network);
|
var path = Helper.getUserLogsPath(user, network);
|
||||||
mkdirp.sync(path);
|
fsextra.ensureDirSync(path);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log.error("Unabled to create logs directory", e);
|
log.error("Unabled to create logs directory", e);
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user