extract setICUEnvVariable() to it's own module

This commit is contained in:
Eneko Lakasta 2018-01-11 11:57:11 +01:00
parent 4d11403be2
commit ae48a01e26
3 changed files with 20 additions and 22 deletions

13
app.js
View File

@ -4,7 +4,7 @@ var path = require('path');
var fs = require('fs'); var fs = require('fs');
var _ = require('underscore'); var _ = require('underscore');
var semver = require('semver'); var semver = require('semver');
const glob = require('glob'); const setICUEnvVariable = require('./lib/cartodb/utils/icu_data_env_setter');
// jshint undef:false // jshint undef:false
var log = console.log.bind(console); var log = console.log.bind(console);
@ -17,18 +17,7 @@ if (!semver.satisfies(nodejsVersion, '>=6.9.0')) {
process.exit(1); process.exit(1);
} }
// See https://github.com/CartoDB/support/issues/984
// CartoCSS properties text-wrap-width/text-wrap-character not working
// This function should be called before the require('yargs'). // This function should be called before the require('yargs').
function setICUEnvVariable() {
if (process.env.ICU_DATA === undefined) {
let directory = glob.sync(__dirname + '/node_modules/mapnik/lib/binding/*/share/mapnik/icu/');
if (directory && directory.length > 0) {
process.env.ICU_DATA = directory[0];
}
}
}
setICUEnvVariable(); setICUEnvVariable();
var argv = require('yargs') var argv = require('yargs')

View File

@ -0,0 +1,18 @@
'use strict';
const glob = require('glob');
const path = require('path');
// See https://github.com/CartoDB/support/issues/984
// CartoCSS properties text-wrap-width/text-wrap-character not working
function setICUEnvVariable() {
if (process.env.ICU_DATA === undefined) {
let directory = glob.sync(path.join(__dirname, '../../..', '/node_modules/mapnik/lib/binding/*/share/mapnik/icu/'));
if (directory && directory.length > 0) {
process.env.ICU_DATA = directory[0];
}
}
}
module.exports = setICUEnvVariable;

View File

@ -15,22 +15,13 @@ var redis = require('redis');
var nock = require('nock'); var nock = require('nock');
var log4js = require('log4js'); var log4js = require('log4js');
var pg = require('pg'); var pg = require('pg');
const setICUEnvVariable = require('../../lib/cartodb/utils/icu_data_env_setter');
// set environment specific variables // set environment specific variables
global.environment = require(__dirname + '/../../config/environments/test'); global.environment = require(__dirname + '/../../config/environments/test');
global.environment.name = 'test'; global.environment.name = 'test';
process.env.NODE_ENV = 'test'; process.env.NODE_ENV = 'test';
// See https://github.com/CartoDB/support/issues/984
// CartoCSS properties text-wrap-width/text-wrap-character not working
function setICUEnvVariable() {
const glob = require('glob');
const path = require('path');
let directory = glob.sync(path.join(__dirname, '../..', '/node_modules/mapnik/lib/binding/*/share/mapnik/icu/'));
if (directory && directory.length > 0) {
process.env.ICU_DATA = directory[0];
}
}
setICUEnvVariable(); setICUEnvVariable();
// don't output logs in test environment to reduce noise // don't output logs in test environment to reduce noise