Use node path for prefix detection, not dirname of library.

This commit is contained in:
Tim Caswell 2017-07-07 12:35:01 -06:00 committed by Tim Caswell
parent dede840a59
commit 2aa6d8d9ee
4 changed files with 9 additions and 9 deletions

View File

@ -40,8 +40,8 @@ var info = {
, externalPortInsecure: walnut.externalInsecurePort || 80 // TODO externalInsecurePort , externalPortInsecure: walnut.externalInsecurePort || 80 // TODO externalInsecurePort
, localPort: walnut.localPort || 3000 // system / local network , localPort: walnut.localPort || 3000 // system / local network
, trustProxy: true , trustProxy: true
, varpath: path.join(__dirname, '..', '..', 'var') , varpath: path.join(process.execPath, '..', '..', 'var')
, etcpath: path.join(__dirname, '..', '..', 'etc') , etcpath: path.join(process.execPath, '..', '..', 'etc')
} }
}; };

View File

@ -13,10 +13,10 @@ module.exports.create = function (xconfx, apiFactories, apiDeps) {
var crypto = require('crypto'); var crypto = require('crypto');
// TODO xconfx.apispath // TODO xconfx.apispath
xconfx.restPath = path.join(__dirname, '..', '..', 'packages', 'rest'); xconfx.restPath = path.join(process.execPath, '..', '..', 'packages', 'rest');
xconfx.apiPath = path.join(__dirname, '..', '..', 'packages', 'api'); xconfx.apiPath = path.join(process.execPath, '..', '..', 'packages', 'api');
xconfx.appApiGrantsPath = path.join(__dirname, '..', '..', 'packages', 'client-api-grants'); xconfx.appApiGrantsPath = path.join(process.execPath, '..', '..', 'packages', 'client-api-grants');
xconfx.appConfigPath = path.join(__dirname, '..', '..', 'var'); xconfx.appConfigPath = path.join(process.execPath, '..', '..', 'var');
function notConfigured(req, res) { function notConfigured(req, res) {
var msg = "api package '" + req.pkgId + "' not configured for client uri '" + req.experienceId + "'" var msg = "api package '" + req.pkgId + "' not configured for client uri '" + req.experienceId + "'"

4
lib/bootstrap.js vendored
View File

@ -109,7 +109,7 @@ module.exports.create = function (app, xconfx, models) {
} }
var configpath = path.join(__dirname, '..', '..', 'config', config.domain + '.json'); var configpath = path.join(process.execPath, '..', '..', 'config', config.domain + '.json');
safeConfig = { primaryDomain: config.domain }; safeConfig = { primaryDomain: config.domain };
xconfx.primaryDomain = safeConfig.primaryDomain; xconfx.primaryDomain = safeConfig.primaryDomain;
return fs.writeFileAsync(configpath, JSON.stringify(safeConfig, null, ' '), 'utf8').then(function () { return fs.writeFileAsync(configpath, JSON.stringify(safeConfig, null, ' '), 'utf8').then(function () {
@ -166,7 +166,7 @@ module.exports.create = function (app, xconfx, models) {
app.post('/api/com.daplie.walnut.init', setConfig); app.post('/api/com.daplie.walnut.init', setConfig);
// TODO use package loader // TODO use package loader
//app.use('/', express.static(path.join(__dirname, '..', '..', 'packages', 'pages', 'com.daplie.walnut.init'))); //app.use('/', express.static(path.join(process.execPath, '..', '..', 'packages', 'pages', 'com.daplie.walnut.init')));
app.use('/', express.static(path.join(__dirname, 'com.daplie.walnut.init'))); app.use('/', express.static(path.join(__dirname, 'com.daplie.walnut.init')));
app.use('/', function (req, res, next) { app.use('/', function (req, res, next) {
res.statusCode = 404; res.statusCode = 404;

View File

@ -168,7 +168,7 @@ module.exports.create = function (webserver, xconfx, state) {
if (hostname && !hostsmap[hostname]) { if (hostname && !hostsmap[hostname]) {
hostsmap[hostname] = true; hostsmap[hostname] = true;
require('fs').writeFile( require('fs').writeFile(
require('path').join(__dirname, '..', '..', 'var', 'hostnames', hostname) require('path').join(process.execPath, '..', '..', 'var', 'hostnames', hostname)
, hostname , hostname
, function () {} , function () {}
); );