This commit is contained in:
Christopher Jeffrey 2016-05-24 01:00:46 -07:00
parent da701cbef4
commit e2626c32f0
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
2 changed files with 24 additions and 26 deletions

View File

@ -5,7 +5,7 @@ var utils = bcoin.utils;
var assert = utils.assert;
process.on('uncaughtException', function(err) {
bcoin.debug(err ? err.stack + '' : err + '');
bcoin.error(err);
process.exit(1);
});

View File

@ -9,11 +9,8 @@ var utils = require('./utils');
var assert = utils.assert;
var fs;
try {
if (!utils.isBrowser)
fs = require('f' + 's');
} catch (e) {
;
}
/**
* A BCoin "environment" which is used for
@ -383,42 +380,43 @@ Environment.prototype.now = function now() {
/**
* Create a full directory structure.
* @param {String} dir
* @param {String} path
*/
function mkdirp(dir) {
var path = require('path');
var i, parts, name;
function mkdirp(path) {
var i, parts;
if (!fs)
return;
dir = path.normalize(dir);
dir = dir.replace(/\\/g, '/');
dir = dir.replace(/\/$/, '');
parts = dir.split('/');
path = path.replace(/\\/g, '/');
path = path.replace(/\/+$/, '');
parts = path.split(/\/+/);
path = '';
if (process.platform === 'win32') {
if (parts[0].indexOf(':') !== -1)
path = parts.shift() + '/';
}
if (parts[0].length === 0) {
parts.shift();
path = '/';
}
for (i = 0; i < parts.length; i++) {
if (i === 0) {
if (process.platform === 'win32') {
if (parts[0].indexOf(':') !== -1)
continue;
} else {
if (parts[0].length === 0)
continue;
}
}
name = parts.slice(0, i + 1).join('/');
path += parts[i];
try {
fs.statSync(name);
fs.statSync(path);
} catch (e) {
if (e.code === 'ENOENT')
fs.mkdirSync(name, 488 /* 0750 */);
fs.mkdirSync(path, 488 /* 0750 */);
else
throw e;
}
path += '/';
}
}