Do not use string concatenation when using __dirname and __filename
This commit is contained in:
parent
da0d0d21e3
commit
ad4a1ada45
@ -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 }) {
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
|
@ -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');
|
||||
|
@ -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);
|
||||
|
@ -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');
|
||||
|
@ -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' });
|
||||
|
@ -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' }, {});
|
||||
});
|
||||
|
@ -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);
|
||||
|
@ -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');
|
||||
|
@ -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')
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -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');
|
||||
|
Loading…
Reference in New Issue
Block a user