diff --git a/tasks/compile-translations-po-to-json.js b/tasks/compile-translations-po-to-json.js index f307b2e4d9..2a0b87a1ca 100644 --- a/tasks/compile-translations-po-to-json.js +++ b/tasks/compile-translations-po-to-json.js @@ -2,6 +2,7 @@ var fs = require('fs'); var path = require('path'); var execSync = require('child_process').execSync; var _ = require('lodash'); +var {getModuleDir} = require('./get-module-directory'); function isDirectory(path) { try { @@ -82,7 +83,7 @@ function compileTranslationsPoToJson(grunt) { return; } - var po2json = path.join(clientCoreRoot, 'node_modules/gettext.js/bin/po2json'); + var po2json = `${getModuleDir('gettext.js')}/bin/po2json`; var poFile = `${translationsPoDir}/${filename}`; var jsonFile = `${translationsJsonDir}/${filename.replace('.po', '.json')}`; diff --git a/tasks/get-module-directory.js b/tasks/get-module-directory.js new file mode 100644 index 0000000000..4097fe3c93 --- /dev/null +++ b/tasks/get-module-directory.js @@ -0,0 +1,9 @@ +var path = require('path'); + +function getModuleDir(moduleName) { + return path.join(require.resolve(moduleName + '/package.json'), '../'); +} + +module.exports = { + getModuleDir: getModuleDir, +}; diff --git a/webpack.config.js b/webpack.config.js index 634ddcd826..412d0d3d05 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -2,6 +2,7 @@ var path = require('path'); var webpack = require('webpack'); var lodash = require('lodash'); const ExtractTextPlugin = require('extract-text-webpack-plugin'); +var {getModuleDir} = require('./tasks/get-module-directory'); function countOccurences(_string, substring) { return _string.split(substring).length - 1; @@ -25,7 +26,7 @@ module.exports = function makeConfig(grunt) { // include only 'superdesk-core' and valid modules inside node_modules let validModules = ['superdesk-core'].concat(apps); - const jQueryModule = `${__dirname}/node_modules/jquery`; + const jQueryModule = getModuleDir('jquery'); return { entry: {