Skip to content

Commit 90e1c36

Browse files
committed
fix installation from npm3
npm3 will flatten node_modules, so the nested node_modules that is used for copying the JSON over from Topojson will not be available in the package's relative node_modules. This commit uses a synchronous check to see if the path is valid and on failure with try to use the path expected from npm3 installations.
1 parent d508db7 commit 90e1c36

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

tasks/util/constants.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
1+
var fs = require('fs');
12
var path = require('path');
23

34
var pathToRoot = path.join(__dirname, '../../');
5+
var pathToRootParent = path.join(__dirname, '../../../../');
46
var pathToSrc = path.join(pathToRoot, 'src/');
57
var pathToImageTest = path.join(pathToRoot, 'test/image');
68
var pathToDist = path.join(pathToRoot, 'dist/');
79
var pathToBuild = path.join(pathToRoot, 'build/');
810

11+
var pathToTopojsonSrc;
12+
13+
try {
14+
pathToTopojsonSrc = path.join(pathToRoot, 'node_modules/sane-topojson/dist/');
15+
fs.statSync(pathToTopojsonSrc);
16+
} catch (e) {
17+
pathToTopojsonSrc = path.join(pathToRootParent, 'node_modules/sane-topojson/dist/');
18+
}
19+
920
module.exports = {
1021
pathToRoot: pathToRoot,
1122
pathToSrc: pathToSrc,
@@ -17,7 +28,7 @@ module.exports = {
1728
pathToPlotlyDistMin: path.join(pathToDist, 'plotly.min.js'),
1829
pathToPlotlyDistWithMeta: path.join(pathToDist, 'plotly-with-meta.js'),
1930

20-
pathToTopojsonSrc: path.join(pathToRoot, 'node_modules/sane-topojson/dist/'),
31+
pathToTopojsonSrc: pathToTopojsonSrc,
2132
pathToTopojsonDist: path.join(pathToDist, 'topojson/'),
2233
pathToPlotlyGeoAssetsSrc: path.join(pathToSrc, 'assets/geo_assets.js'),
2334
pathToPlotlyGeoAssetsDist: path.join(pathToDist, 'plotly-geo-assets.js'),

0 commit comments

Comments
 (0)