Skip to content

Commit

Permalink
Merge pull request #390 from hogofwar/master
Browse files Browse the repository at this point in the history
Supersede mkdirp with fs-extra
  • Loading branch information
maxpoulin64 authored Jun 11, 2016
2 parents 1744b8f + 3a2d97a commit ee0ebdc
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 25 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
"fs-extra": "0.30.0",
"irc-framework": "2.0.0",
"lodash": "4.11.2",
"mkdirp": "0.5.1",
"moment": "2.13.0",
"read": "1.0.7",
"request": "2.72.0",
Expand Down
3 changes: 0 additions & 3 deletions src/clientManager.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
var _ = require("lodash");
var fs = require("fs");
var Client = require("./client");
var mkdirp = require("mkdirp");
var Helper = require("./helper");
var oidentd = require("./oidentd");

Expand Down Expand Up @@ -52,7 +51,6 @@ ClientManager.prototype.loadUser = function(name) {

ClientManager.prototype.getUsers = function() {
var users = [];
mkdirp.sync(Helper.USERS_PATH);
try {
var files = fs.readdirSync(Helper.USERS_PATH);
files.forEach(function(file) {
Expand All @@ -73,7 +71,6 @@ ClientManager.prototype.addUser = function(name, password) {
return false;
}
try {
mkdirp.sync(Helper.USERS_PATH);

if (require("path").basename(name) !== name) {
throw new Error(name + " is an invalid username.");
Expand Down
7 changes: 0 additions & 7 deletions src/command-line/add.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
var ClientManager = new require("../clientManager");
var bcrypt = require("bcrypt-nodejs");
var program = require("commander");
var mkdirp = require("mkdirp");
var Helper = require("../helper");

program
.command("add <name>")
.description("Add a new user")
.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 users = manager.getUsers();
if (users.indexOf(name) !== -1) {
Expand Down
24 changes: 12 additions & 12 deletions src/command-line/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ global.log = require("../log.js");
var program = require("commander");
var pkg = require("../../package.json");
var fs = require("fs");
var mkdirp = require("mkdirp");
var fsextra = require("fs-extra");
var path = require("path");
var Helper = require("../helper");

Expand All @@ -16,20 +16,20 @@ var argv = program.parseOptions(process.argv);
Helper.setHome(program.home);

if (!fs.existsSync(Helper.CONFIG_PATH)) {
mkdirp.sync(Helper.HOME, {mode: "0700"});
fs.writeFileSync(
Helper.CONFIG_PATH,
fs.readFileSync(path.resolve(path.join(
__dirname,
"..",
"..",
"defaults",
"config.js"
)))
);
fsextra.ensureDirSync(Helper.HOME);
fs.chmodSync(Helper.HOME, "0700");
fsextra.copySync(path.resolve(path.join(
__dirname,
"..",
"..",
"defaults",
"config.js"
)), Helper.CONFIG_PATH);
log.info("Config created:", Helper.CONFIG_PATH);
}

fsextra.ensureDirSync(Helper.USERS_PATH);

require("./start");
require("./config");
require("./list");
Expand Down
4 changes: 2 additions & 2 deletions src/userLog.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
var fs = require("fs");
var mkdirp = require("mkdirp");
var fsextra = require("fs-extra");
var moment = require("moment");
var Helper = require("./helper");

module.exports.write = function(user, network, chan, msg) {
try {
var path = Helper.getUserLogsPath(user, network);
mkdirp.sync(path);
fsextra.ensureDirSync(path);
} catch (e) {
log.error("Unabled to create logs directory", e);
return;
Expand Down

0 comments on commit ee0ebdc

Please sign in to comment.