diff --git a/lib/api/api-router.js b/lib/api/api-router.js index 605e612b..f0ba1056 100644 --- a/lib/api/api-router.js +++ b/lib/api/api-router.js @@ -1,5 +1,7 @@ 'use strict'; +const path = require('path'); + const { Router: router } = require('express'); const RedisPool = require('redis-mpool'); @@ -280,7 +282,7 @@ function createSurrogateKeysCacheBackends (serverOptions) { return cacheBackends; } -const timeoutErrorTilePath = __dirname + '/../../assets/render-timeout-fallback.png'; +const timeoutErrorTilePath = path.join(__dirname, '/../../assets/render-timeout-fallback.png'); const timeoutErrorTile = require('fs').readFileSync(timeoutErrorTilePath, { encoding: null }); function createRendererFactory ({ redisPool, serverOptions, environmentOptions }) { diff --git a/lib/api/middlewares/vector-error.js b/lib/api/middlewares/vector-error.js index 78b67787..b1cce3ac 100644 --- a/lib/api/middlewares/vector-error.js +++ b/lib/api/middlewares/vector-error.js @@ -1,7 +1,8 @@ 'use strict'; const fs = require('fs'); -const timeoutErrorVectorTile = fs.readFileSync(__dirname + '/../../../assets/render-timeout-fallback.mvt'); +const path = require('path'); +const timeoutErrorVectorTile = fs.readFileSync(path.join(__dirname, '/../../../assets/render-timeout-fallback.mvt')); module.exports = function vectorError () { return function vectorErrorMiddleware (err, req, res, next) { diff --git a/test/acceptance/multilayer-test.js b/test/acceptance/multilayer-test.js index f0ddbac7..9aaef863 100644 --- a/test/acceptance/multilayer-test.js +++ b/test/acceptance/multilayer-test.js @@ -1,5 +1,6 @@ 'use strict'; +var path = require('path'); var assert = require('../support/assert'); var _ = require('underscore'); var redis = require('redis'); @@ -13,7 +14,7 @@ var semver = require('semver'); var helper = require('../support/test-helper'); var LayergroupToken = require('../../lib/models/layergroup-token'); -var windshaft_fixtures = __dirname + '/../../node_modules/windshaft/test/fixtures'; +var windshaft_fixtures = path.join(__dirname, '/../../node_modules/windshaft/test/fixtures'); var IMAGE_EQUALS_TOLERANCE_PER_MIL = 20; var IMAGE_EQUALS_HIGHER_TOLERANCE_PER_MIL = 25; diff --git a/test/acceptance/ported/blend-filtering-test.js b/test/acceptance/ported/blend-filtering-test.js index 909cd683..3cda28a4 100644 --- a/test/acceptance/ported/blend-filtering-test.js +++ b/test/acceptance/ported/blend-filtering-test.js @@ -5,6 +5,7 @@ require('../../support/test-helper'); var assert = require('../../support/assert'); var testClient = require('./support/test-client'); var fs = require('fs'); +var path = require('path'); var http = require('http'); describe('blend layer filtering', function () { @@ -15,7 +16,7 @@ describe('blend layer filtering', function () { before(function (done) { // Start a server to test external resources httpRendererResourcesServer = http.createServer(function (request, response) { - var filename = __dirname + '/../../fixtures/http/light_nolabels-1-0-0.png'; + var filename = path.join(__dirname, '/../../fixtures/http/light_nolabels-1-0-0.png'); fs.readFile(filename, { encoding: 'binary' }, function (err, file) { response.writeHead(200); response.write(file, 'binary'); diff --git a/test/acceptance/ported/blend-http-fallback-test.js b/test/acceptance/ported/blend-http-fallback-test.js index d31deed9..59e5a61a 100644 --- a/test/acceptance/ported/blend-http-fallback-test.js +++ b/test/acceptance/ported/blend-http-fallback-test.js @@ -6,6 +6,7 @@ var assert = require('../../support/assert'); var testClient = require('./support/test-client'); var fs = require('fs'); var http = require('http'); +var path = require('path'); describe('blend http fallback', function () { var IMG_TOLERANCE_PER_MIL = 20; @@ -19,9 +20,9 @@ describe('blend http fallback', function () { response.writeHead(404); response.end(); } else { - var filename = __dirname + '/../../fixtures/http/light_nolabels-1-0-0.png'; + var filename = path.join(__dirname, '/../../fixtures/http/light_nolabels-1-0-0.png'); if (request.url.match(/^\/dark\//)) { - filename = __dirname + '/../../fixtures/http/dark_nolabels-1-0-0.png'; + filename = path.join(__dirname, '/../../fixtures/http/dark_nolabels-1-0-0.png'); } fs.readFile(filename, { encoding: 'binary' }, function (err, file) { response.writeHead(200); diff --git a/test/acceptance/ported/blend-http-timeout-test.js b/test/acceptance/ported/blend-http-timeout-test.js index 11d82f66..60822ef5 100644 --- a/test/acceptance/ported/blend-http-timeout-test.js +++ b/test/acceptance/ported/blend-http-timeout-test.js @@ -7,6 +7,7 @@ var testClient = require('./support/test-client'); var serverOptions = require('./support/ported-server-options'); var fs = require('fs'); var http = require('http'); +var path = require('path'); describe.skip('blend http client timeout', function () { var mapConfig = { @@ -43,7 +44,7 @@ describe.skip('blend http client timeout', function () { // Start a server to test external resources slowHttpRendererResourcesServer = http.createServer(function (request, response) { setTimeout(function () { - var filename = __dirname + '/../fixtures/http/light_nolabels-1-0-0.png'; + var filename = path.join(__dirname, '/../fixtures/http/light_nolabels-1-0-0.png'); fs.readFile(filename, { encoding: 'binary' }, function (err, file) { response.writeHead(200); response.write(file, 'binary'); diff --git a/test/acceptance/ported/external-resources-test.js b/test/acceptance/ported/external-resources-test.js index bb8f3248..68dc53d7 100644 --- a/test/acceptance/ported/external-resources-test.js +++ b/test/acceptance/ported/external-resources-test.js @@ -8,6 +8,7 @@ var PortedServerOptions = require('./support/ported-server-options'); var http = require('http'); var testClient = require('./support/test-client'); var nock = require('nock'); +var path = require('path'); describe('external resources', function () { var res_serv; // resources server @@ -20,7 +21,7 @@ describe('external resources', function () { // Start a server to test external resources res_serv = http.createServer(function (request, response) { ++res_serv_status.numrequests; - var filename = __dirname + '/../../fixtures/markers' + request.url; + var filename = path.join(__dirname, '/../../fixtures/markers', request.url); fs.readFile(filename, 'binary', function (err, file) { if (err) { response.writeHead(404, { 'Content-Type': 'text/plain' }); diff --git a/test/acceptance/ported/limits-test.js b/test/acceptance/ported/limits-test.js index 8bf4c385..8c81f0db 100644 --- a/test/acceptance/ported/limits-test.js +++ b/test/acceptance/ported/limits-test.js @@ -3,6 +3,7 @@ require('../../support/test-helper'); var fs = require('fs'); +var path = require('path'); var assert = require('../../support/assert'); var testClient = require('./support/test-client'); @@ -47,7 +48,7 @@ describe.skip('render limits', function () { it('uses onTileErrorStrategy to handle error and modify response', function (done) { serverOptions.renderer.onTileErrorStrategy = function (err, tile, headers, stats, format, callback) { - var fixture = __dirname + '/../../fixtures/limits/fallback.png'; + var fixture = path.join(__dirname, '/../../fixtures/limits/fallback.png'); fs.readFile(fixture, { encoding: 'binary' }, function (err, img) { callback(null, img, { 'Content-Type': 'image/png' }, {}); }); diff --git a/test/acceptance/ported/server-png8-format-test.js b/test/acceptance/ported/server-png8-format-test.js index dd02f36b..12376fac 100644 --- a/test/acceptance/ported/server-png8-format-test.js +++ b/test/acceptance/ported/server-png8-format-test.js @@ -5,6 +5,7 @@ var testHelper = require('../../support/test-helper'); var assert = require('../../support/assert'); var _ = require('underscore'); var fs = require('fs'); +var path = require('path'); var cartodbServer = require('../../../lib/server'); var ServerOptions = require('./support/ported-server-options'); @@ -33,7 +34,7 @@ describe('server_png8_format', function () { var layergroupId; before(function (done) { - var testPngFilesDir = __dirname + '/../../results/png'; + var testPngFilesDir = path.join(__dirname, '/../../results/png'); fs.readdirSync(testPngFilesDir) .filter(function (fileName) { return /.*\.png$/.test(fileName); diff --git a/test/acceptance/ported/static-maps-test.js b/test/acceptance/ported/static-maps-test.js index ddc72c01..04f3fdca 100644 --- a/test/acceptance/ported/static-maps-test.js +++ b/test/acceptance/ported/static-maps-test.js @@ -6,6 +6,7 @@ var assert = require('../../support/assert'); var testClient = require('./support/test-client'); var http = require('http'); var fs = require('fs'); +var path = require('path'); describe('static_maps', function () { var validUrlTemplate = 'http://127.0.0.1:8033/{s}/{z}/{x}/{y}.png'; @@ -16,7 +17,7 @@ describe('static_maps', function () { before(function (done) { // Start a server to test external resources httpRendererResourcesServer = http.createServer(function (request, response) { - var filename = __dirname + '/../../fixtures/http/basemap.png'; + var filename = path.join(__dirname, '/../../fixtures/http/basemap.png'); fs.readFile(filename, { encoding: 'binary' }, function (err, file) { response.writeHead(200); response.write(file, 'binary'); diff --git a/test/acceptance/ported/support/ported-server-options.js b/test/acceptance/ported/support/ported-server-options.js index 7140e565..06fe30fa 100644 --- a/test/acceptance/ported/support/ported-server-options.js +++ b/test/acceptance/ported/support/ported-server-options.js @@ -7,6 +7,7 @@ var OverviewsQueryRewriter = require('../../../../lib/utils/overviews-query-rewr var overviewsQueryRewriter = new OverviewsQueryRewriter({ zoom_level: 'CDB_ZoomFromScale(!scale_denominator!)' }); +var path = require('path'); module.exports = _.extend({}, serverOptions, { grainstore: { @@ -39,7 +40,7 @@ module.exports = _.extend({}, serverOptions, { whitelist: ['http://127.0.0.1:8033/{s}/{z}/{x}/{y}.png'], fallbackImage: { type: 'fs', - src: __dirname + '/../../test/fixtures/http/basemap.png' + src: path.join(__dirname, '/../../test/fixtures/http/basemap.png') } } }, diff --git a/test/acceptance/templates-test.js b/test/acceptance/templates-test.js index 92a1063e..d3fd54fe 100644 --- a/test/acceptance/templates-test.js +++ b/test/acceptance/templates-test.js @@ -15,6 +15,7 @@ var redis_stats_db = 5; process.env.PGPORT = '666'; process.env.PGHOST = 'fake'; +var path = require('path'); var fs = require('fs'); var http = require('http'); @@ -39,7 +40,7 @@ describe('template_api', function () { before(function (done) { // Start a server to test external resources httpRendererResourcesServer = http.createServer(function (request, response) { - var filename = __dirname + '/../fixtures/http/light_nolabels-1-0-0.png'; + var filename = path.join(__dirname, '/../fixtures/http/light_nolabels-1-0-0.png'); fs.readFile(filename, { encoding: 'binary' }, function (err, file) { response.writeHead(200); response.write(file, 'binary');