made sure the var dir can be created if needed
looks like the var directory is not present when goldilocks is npm installed
This commit is contained in:
parent
dda3dffb17
commit
d5dee498f5
|
@ -94,7 +94,13 @@ module.exports = function (myDeps, conf, overrideHttp) {
|
|||
obj.id = id;
|
||||
owners[id] = obj;
|
||||
|
||||
return fs.writeFileAsync(ownersPath, JSON.stringify(owners), 'utf8');
|
||||
return fs.mkdirAsync(path.dirname(ownersPath)).catch(function (err) {
|
||||
if (err.code !== 'EEXIST') {
|
||||
console.error('failed to mkdir', path.dirname(ownersPath), err.toString());
|
||||
}
|
||||
}).then(function () {
|
||||
return fs.writeFileAsync(ownersPath, JSON.stringify(owners), 'utf8');
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
|
12
lib/mdns.js
12
lib/mdns.js
|
@ -2,7 +2,8 @@
|
|||
|
||||
var PromiseA = require('bluebird');
|
||||
var fs = PromiseA.promisifyAll(require('fs'));
|
||||
var idFilename = require('path').join(__dirname, '..', 'var', 'mdns-id');
|
||||
var path = require('path');
|
||||
var idFilename = path.join(__dirname, '..', 'var', 'mdns-id');
|
||||
var queryName = '_cloud._tcp.local';
|
||||
|
||||
var randomId = {
|
||||
|
@ -18,10 +19,15 @@ var randomId = {
|
|||
}
|
||||
|
||||
, set: function (value) {
|
||||
return fs.writeFileAsync(idFilename, value)
|
||||
.then(function () {
|
||||
return fs.mkdirAsync(path.dirname(idFilename)).catch(function (err) {
|
||||
if (err.code !== 'EEXIST') {
|
||||
console.error('failed to mkdir', path.dirname(idFilename), err.toString());
|
||||
}
|
||||
}).then(function () {
|
||||
return fs.writeFileAsync(idFilename, value).then(function () {
|
||||
return value;
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -6,7 +6,8 @@ module.exports.create = function (deps, config) {
|
|||
var stunnel = require('stunnel');
|
||||
var activeTunnels = {};
|
||||
|
||||
var tokensPath = require('path').join(__dirname, '..', 'var', 'tokens.json');
|
||||
var path = require('path');
|
||||
var tokensPath = path.join(__dirname, '..', 'var', 'tokens.json');
|
||||
var storage = {
|
||||
_read: function () {
|
||||
var tokens;
|
||||
|
@ -18,7 +19,13 @@ module.exports.create = function (deps, config) {
|
|||
return tokens;
|
||||
}
|
||||
, _write: function (tokens) {
|
||||
return fs.writeFileAsync(tokensPath, JSON.stringify(tokens), 'utf8');
|
||||
return fs.mkdirAsync(path.dirname(tokensPath)).catch(function (err) {
|
||||
if (err.code !== 'EEXIST') {
|
||||
console.error('failed to mkdir', path.dirname(tokensPath), err.toString());
|
||||
}
|
||||
}).then(function () {
|
||||
return fs.writeFileAsync(tokensPath, JSON.stringify(tokens), 'utf8');
|
||||
});
|
||||
}
|
||||
|
||||
, all: function () {
|
||||
|
|
Loading…
Reference in New Issue