diff --git a/.circleci/config.yml b/.circleci/config.yml index f7b260b35e1..a2db5382754 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -166,12 +166,12 @@ jobs: echo https://$CIRCLE_BUILD_NUM-$PROJECT_NUM-gh.circle-artifacts.com/0/dist/plotly.js echo https://$CIRCLE_BUILD_NUM-$PROJECT_NUM-gh.circle-artifacts.com/0/dist/plotly.min.js echo https://$CIRCLE_BUILD_NUM-$PROJECT_NUM-gh.circle-artifacts.com/0/dist/plot-schema.json - - run: - name: Test certain bundles against function constructors - command: npm run no-new-func - run: name: Test plotly bundles againt unexpected characters command: npm run no-bad-char + - run: + name: Test certain bundles against function constructors + command: npm run no-new-func workflows: version: 2 diff --git a/lib/index-basic.js b/lib/index-basic.js index e445f45122d..ca431c84c6d 100644 --- a/lib/index-basic.js +++ b/lib/index-basic.js @@ -15,5 +15,4 @@ Plotly.register([ require('./pie') ]); -require('./register_extra')(Plotly); -module.exports = Plotly; +module.exports = require('./register_extra')(Plotly); diff --git a/lib/index-cartesian.js b/lib/index-cartesian.js index 50a1fcd09b7..94167d90d52 100644 --- a/lib/index-cartesian.js +++ b/lib/index-cartesian.js @@ -24,5 +24,4 @@ Plotly.register([ require('./violin') ]); -require('./register_extra')(Plotly); -module.exports = Plotly; +module.exports = require('./register_extra')(Plotly); diff --git a/lib/index-finance.js b/lib/index-finance.js index f6491a52d05..2f9be8733b8 100644 --- a/lib/index-finance.js +++ b/lib/index-finance.js @@ -22,5 +22,4 @@ Plotly.register([ require('./indicator') ]); -require('./register_extra')(Plotly); -module.exports = Plotly; +module.exports = require('./register_extra')(Plotly); diff --git a/lib/index-geo.js b/lib/index-geo.js index 1a673119f57..0bb5fb2145f 100644 --- a/lib/index-geo.js +++ b/lib/index-geo.js @@ -15,5 +15,4 @@ Plotly.register([ require('./choropleth') ]); -require('./register_extra')(Plotly); -module.exports = Plotly; +module.exports = require('./register_extra')(Plotly); diff --git a/lib/index-gl2d.js b/lib/index-gl2d.js index 20b75b60868..ad78095ed80 100644 --- a/lib/index-gl2d.js +++ b/lib/index-gl2d.js @@ -17,5 +17,4 @@ Plotly.register([ require('./parcoords') ]); -require('./register_extra')(Plotly); -module.exports = Plotly; +module.exports = require('./register_extra')(Plotly); diff --git a/lib/index-gl3d.js b/lib/index-gl3d.js index de23519bc76..800995e5608 100644 --- a/lib/index-gl3d.js +++ b/lib/index-gl3d.js @@ -20,5 +20,4 @@ Plotly.register([ require('./streamtube') ]); -require('./register_extra')(Plotly); -module.exports = Plotly; +module.exports = require('./register_extra')(Plotly); diff --git a/lib/index-mapbox.js b/lib/index-mapbox.js index ef337768dbb..272387d9810 100644 --- a/lib/index-mapbox.js +++ b/lib/index-mapbox.js @@ -16,5 +16,4 @@ Plotly.register([ require('./densitymapbox') ]); -require('./register_extra')(Plotly); -module.exports = Plotly; +module.exports = require('./register_extra')(Plotly); diff --git a/lib/index-strict.js b/lib/index-strict.js index 24b5f21295b..43948f1e68e 100644 --- a/lib/index-strict.js +++ b/lib/index-strict.js @@ -56,5 +56,4 @@ Plotly.register([ require('./barpolar') ]); -require('./register_extra')(Plotly); -module.exports = Plotly; +module.exports = require('./register_extra')(Plotly); diff --git a/lib/index.js b/lib/index.js index 4cf645eecbe..72930ceb362 100644 --- a/lib/index.js +++ b/lib/index.js @@ -71,5 +71,4 @@ Plotly.register([ require('./barpolar') ]); -require('./register_extra')(Plotly); -module.exports = Plotly; +module.exports = require('./register_extra')(Plotly); diff --git a/lib/register_extra.js b/lib/register_extra.js index 822125b419d..896edf5cb38 100644 --- a/lib/register_extra.js +++ b/lib/register_extra.js @@ -30,4 +30,6 @@ module.exports = function registerExtra(Plotly) { Plotly.register([ require('./calendars') ]); + + return Plotly; }; diff --git a/tasks/compress_attributes.js b/tasks/compress_attributes.js index 0fe6f1158d7..139086e8900 100644 --- a/tasks/compress_attributes.js +++ b/tasks/compress_attributes.js @@ -8,36 +8,46 @@ var through = require('through2'); // one line string with or without trailing comma function makeStringRegex(attr) { - return attr + ': \'.*\'' + ',?'; + return makeRegex( + attr + ': \'.*\'' + ',?' + ); } // joined array of strings with or without trailing comma function makeJoinedArrayRegex(attr) { - return attr + ': \\[[\\s\\S]*?\\]' + '\\.join\\(.*' + ',?'; + return makeRegex( + attr + ': \\[[\\s\\S]*?\\]' + '\\.join\\(.*' + ',?' + ); } // array with or without trailing comma function makeArrayRegex(attr) { - return attr + ': \\[[\\s\\S]*?\\]' + ',?'; + return makeRegex( + attr + ': \\[[\\s\\S]*?\\]' + ',?' + ); } -// ref: http://www.regexr.com/3cmac -var regexStr = [ - makeStringRegex('description'), - makeJoinedArrayRegex('description'), - makeArrayRegex('requiredOpts'), - makeArrayRegex('otherOpts'), - makeStringRegex('hrName') -].join('|'); - -var regex = new RegExp(regexStr, 'g'); +function makeRegex(regexStr) { + return ( + new RegExp(regexStr, 'g') + ); +} module.exports = function() { - return through(function(buf, enc, next) { + var allChunks = []; + return through(function(chunk, enc, next) { + allChunks.push(chunk); + next(); + }, function(done) { + var str = Buffer.concat(allChunks).toString('utf-8'); this.push( - buf.toString('utf-8') - .replace(regex, '') + str + .replace(makeStringRegex('description'), '') + .replace(makeJoinedArrayRegex('description'), '') + .replace(makeArrayRegex('requiredOpts'), '') + .replace(makeArrayRegex('otherOpts'), '') + .replace(makeStringRegex('hrName'), '') ); - next(); + done(); }); };