1
+ var fs = require ( 'fs' ) ;
1
2
var path = require ( 'path' ) ;
2
3
3
4
var pathToRoot = path . join ( __dirname , '../../' ) ;
5
+ var pathToRootParent = path . join ( __dirname , '../../../../' ) ;
4
6
var pathToSrc = path . join ( pathToRoot , 'src/' ) ;
5
7
var pathToImageTest = path . join ( pathToRoot , 'test/image' ) ;
6
8
var pathToDist = path . join ( pathToRoot , 'dist/' ) ;
7
9
var pathToBuild = path . join ( pathToRoot , 'build/' ) ;
8
10
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
+
9
22
module . exports = {
10
23
pathToRoot : pathToRoot ,
11
24
pathToSrc : pathToSrc ,
@@ -17,7 +30,7 @@ module.exports = {
17
30
pathToPlotlyDistMin : path . join ( pathToDist , 'plotly.min.js' ) ,
18
31
pathToPlotlyDistWithMeta : path . join ( pathToDist , 'plotly-with-meta.js' ) ,
19
32
20
- pathToTopojsonSrc : path . join ( pathToRoot , 'node_modules/sane-topojson/dist/' ) ,
33
+ pathToTopojsonSrc : pathToTopojsonSrc ,
21
34
pathToTopojsonDist : path . join ( pathToDist , 'topojson/' ) ,
22
35
pathToPlotlyGeoAssetsSrc : path . join ( pathToSrc , 'assets/geo_assets.js' ) ,
23
36
pathToPlotlyGeoAssetsDist : path . join ( pathToDist , 'plotly-geo-assets.js' ) ,
0 commit comments