Skip to content

Commit 0bbfa25

Browse files
committed
Merge pull request #48 from plotly/better-topojson
Use require.resolve to get path to topojson files
2 parents 7c100f5 + 1bd3656 commit 0bbfa25

File tree

2 files changed

+4
-14
lines changed

2 files changed

+4
-14
lines changed

tasks/util/constants.js

+3-13
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,20 @@
1-
var fs = require('fs');
21
var path = require('path');
32

43
var pkg = require('../../package.json');
54

65
var pathToRoot = path.join(__dirname, '../../');
7-
var pathToRootParent = path.join(__dirname, '../../../../');
86
var pathToSrc = path.join(pathToRoot, 'src/');
97
var pathToImageTest = path.join(pathToRoot, 'test/image');
108
var pathToDist = path.join(pathToRoot, 'dist/');
119
var pathToBuild = path.join(pathToRoot, 'build/');
1210

13-
var pathToTopojsonSrc;
14-
15-
// npm3 flattens modules, so they won't be accessible through the old nested npm2 paths
16-
// attempt a synchronous filestat check, and on error, use the npm3 path
17-
try {
18-
pathToTopojsonSrc = path.join(pathToRoot, 'node_modules/sane-topojson/dist/');
19-
fs.statSync(pathToTopojsonSrc);
20-
} catch (e) {
21-
pathToTopojsonSrc = path.join(pathToRootParent, 'node_modules/sane-topojson/dist/');
22-
}
11+
var pathToTopojsonSrc = path.join(
12+
path.dirname(require.resolve('sane-topojson')), 'dist/'
13+
);
2314

2415
module.exports = {
2516
pathToRoot: pathToRoot,
2617
pathToSrc: pathToSrc,
27-
pathToMocks: path.join(pathToRoot, 'test/image/mocks'),
2818

2919
pathToPlotlySrc: path.join(pathToSrc, 'index.js'),
3020
pathToPlotlyBuild: path.join(pathToBuild, 'plotly.js'),

tasks/util/shortcut_paths.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ var constants = require('./constants');
1010

1111
var shortcutsConfig = {
1212
'@src': constants.pathToSrc,
13-
'@mocks': constants.pathToMocks
13+
'@mocks': constants.pathToTestImageMocks
1414
};
1515

1616
module.exports = transformTools.makeRequireTransform('requireTransform',

0 commit comments

Comments
 (0)