Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 734f75f

Browse files
committed
Merge pull request plotly#12 from justinwoo/fix-npm3-install
fix installation from npm3
2 parents d508db7 + 0e78905 commit 734f75f

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

tasks/util/constants.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,24 @@
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+
// npm3 flattens modules, so they won't be accessible through the old nested npm2 paths
14+
// attempt a synchronous filestat check, and on error, use the npm3 path
15+
try {
16+
pathToTopojsonSrc = path.join(pathToRoot, 'node_modules/sane-topojson/dist/');
17+
fs.statSync(pathToTopojsonSrc);
18+
} catch (e) {
19+
pathToTopojsonSrc = path.join(pathToRootParent, 'node_modules/sane-topojson/dist/');
20+
}
21+
922
module.exports = {
1023
pathToRoot: pathToRoot,
1124
pathToSrc: pathToSrc,
@@ -17,7 +30,7 @@ module.exports = {
1730
pathToPlotlyDistMin: path.join(pathToDist, 'plotly.min.js'),
1831
pathToPlotlyDistWithMeta: path.join(pathToDist, 'plotly-with-meta.js'),
1932

20-
pathToTopojsonSrc: path.join(pathToRoot, 'node_modules/sane-topojson/dist/'),
33+
pathToTopojsonSrc: pathToTopojsonSrc,
2134
pathToTopojsonDist: path.join(pathToDist, 'topojson/'),
2235
pathToPlotlyGeoAssetsSrc: path.join(pathToSrc, 'assets/geo_assets.js'),
2336
pathToPlotlyGeoAssetsDist: path.join(pathToDist, 'plotly-geo-assets.js'),

0 commit comments

Comments
 (0)