forked from plotly/plotly.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstrict_d3.js
26 lines (22 loc) · 865 Bytes
/
strict_d3.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
var path = require('path');
var transformTools = require('browserify-transform-tools');
var constants = require('./constants');
var pathToStrictD3Module = path.join(
constants.pathToImageTest,
'strict-d3.js'
);
var normalizedpathToStrictD3Module = pathToStrictD3Module.replace(/\\/g, '/'); // fix npm-sripts for windows users
/**
* Transform `require('d3')` expressions to `require(/path/to/strict-d3.js)`
*/
module.exports = transformTools.makeRequireTransform('requireTransform',
{ evaluateArguments: true, jsFilesOnly: true },
function(args, opts, cb) {
var pathIn = args[0];
var pathOut;
if(pathIn === 'd3' && opts.file !== pathToStrictD3Module) {
pathOut = 'require(\'' + normalizedpathToStrictD3Module + '\')';
}
if(pathOut) return cb(null, pathOut);
else return cb();
});