From 2aa6d8d9eec3c0304ede2a4798585f444e4686d0 Mon Sep 17 00:00:00 2001 From: Tim Caswell Date: Fri, 7 Jul 2017 12:35:01 -0600 Subject: [PATCH] Use node path for prefix detection, not dirname of library. --- boot/master.js | 4 ++-- lib/apis.js | 8 ++++---- lib/bootstrap.js | 4 ++-- lib/worker.js | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/boot/master.js b/boot/master.js index e25c6dd..f18a8be 100644 --- a/boot/master.js +++ b/boot/master.js @@ -40,8 +40,8 @@ var info = { , externalPortInsecure: walnut.externalInsecurePort || 80 // TODO externalInsecurePort , localPort: walnut.localPort || 3000 // system / local network , trustProxy: true - , varpath: path.join(__dirname, '..', '..', 'var') - , etcpath: path.join(__dirname, '..', '..', 'etc') + , varpath: path.join(process.execPath, '..', '..', 'var') + , etcpath: path.join(process.execPath, '..', '..', 'etc') } }; diff --git a/lib/apis.js b/lib/apis.js index bed3111..3d9cbaa 100644 --- a/lib/apis.js +++ b/lib/apis.js @@ -13,10 +13,10 @@ module.exports.create = function (xconfx, apiFactories, apiDeps) { var crypto = require('crypto'); // TODO xconfx.apispath - xconfx.restPath = path.join(__dirname, '..', '..', 'packages', 'rest'); - xconfx.apiPath = path.join(__dirname, '..', '..', 'packages', 'api'); - xconfx.appApiGrantsPath = path.join(__dirname, '..', '..', 'packages', 'client-api-grants'); - xconfx.appConfigPath = path.join(__dirname, '..', '..', 'var'); + xconfx.restPath = path.join(process.execPath, '..', '..', 'packages', 'rest'); + xconfx.apiPath = path.join(process.execPath, '..', '..', 'packages', 'api'); + xconfx.appApiGrantsPath = path.join(process.execPath, '..', '..', 'packages', 'client-api-grants'); + xconfx.appConfigPath = path.join(process.execPath, '..', '..', 'var'); function notConfigured(req, res) { var msg = "api package '" + req.pkgId + "' not configured for client uri '" + req.experienceId + "'" diff --git a/lib/bootstrap.js b/lib/bootstrap.js index 902c158..2043da9 100644 --- a/lib/bootstrap.js +++ b/lib/bootstrap.js @@ -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 }; xconfx.primaryDomain = safeConfig.primaryDomain; 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); // 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('/', function (req, res, next) { res.statusCode = 404; diff --git a/lib/worker.js b/lib/worker.js index 6ddd28b..71ac6b6 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -168,7 +168,7 @@ module.exports.create = function (webserver, xconfx, state) { if (hostname && !hostsmap[hostname]) { hostsmap[hostname] = true; require('fs').writeFile( - require('path').join(__dirname, '..', '..', 'var', 'hostnames', hostname) + require('path').join(process.execPath, '..', '..', 'var', 'hostnames', hostname) , hostname , function () {} );