diff --git a/src/assets/geo_assets.js b/src/assets/geo_assets.js index a66a3942e8e..1c74ed528c5 100644 --- a/src/assets/geo_assets.js +++ b/src/assets/geo_assets.js @@ -9,4 +9,7 @@ var saneTopojson = require('sane-topojson'); +// export the version found in the package.json +exports.version = require('../../package.json').version; + exports.topojson = saneTopojson; diff --git a/src/index.js b/src/index.js index 0b41010c308..fadf663eb17 100644 --- a/src/index.js +++ b/src/index.js @@ -16,6 +16,9 @@ var Plotly = require('./plotly'); +// export the version found in the package.json +exports.version = require('../package.json').version; + // plot api exports.plot = Plotly.plot; exports.newPlot = Plotly.newPlot; diff --git a/tasks/bundle.js b/tasks/bundle.js index 86df8aaf28f..2b13767ddab 100644 --- a/tasks/bundle.js +++ b/tasks/bundle.js @@ -4,7 +4,6 @@ var browserify = require('browserify'); var UglifyJS = require('uglify-js'); var compressAttributes = require('./util/compress_attributes'); -var appendVersion = require('./util/append_version'); var constants = require('./util/constants'); /* @@ -48,19 +47,11 @@ browserify(constants.pathToPlotlySrc, { if(!DEV) { fs.writeFile( constants.pathToPlotlyDistMin, - UglifyJS.minify(buf.toString(), constants.uglifyOptions).code, - function() { - appendVersion( - constants.pathToPlotlyDistMin, {object: 'Plotly'} - ); - } + UglifyJS.minify(buf.toString(), constants.uglifyOptions).code ); } }) -.pipe(fs.createWriteStream(constants.pathToPlotlyDist)) -.on('finish', function() { - appendVersion(constants.pathToPlotlyDist, {object: 'Plotly', DEV: DEV}); -}); +.pipe(fs.createWriteStream(constants.pathToPlotlyDist)); // Browserify the geo assets @@ -70,10 +61,7 @@ browserify(constants.pathToPlotlyGeoAssetsSrc, { .bundle(function(err) { if(err) throw err; }) -.pipe(fs.createWriteStream(constants.pathToPlotlyGeoAssetsDist)) -.on('finish', function() { - appendVersion(constants.pathToPlotlyGeoAssetsDist, {object: 'PlotlyGeoAssets'}); -}); +.pipe(fs.createWriteStream(constants.pathToPlotlyGeoAssetsDist)); // Browserify the plotly.js with meta @@ -84,7 +72,4 @@ browserify(constants.pathToPlotlySrc, { .bundle(function(err) { if(err) throw err; }) -.pipe(fs.createWriteStream(constants.pathToPlotlyDistWithMeta)) -.on('finish', function() { - appendVersion(constants.pathToPlotlyDistWithMeta, {object: 'Plotly', DEV: DEV}); -}); +.pipe(fs.createWriteStream(constants.pathToPlotlyDistWithMeta)); diff --git a/tasks/cibundle.js b/tasks/cibundle.js index 1c37f3b7cd4..8e1db62885d 100644 --- a/tasks/cibundle.js +++ b/tasks/cibundle.js @@ -3,7 +3,6 @@ var fs = require('fs'); var browserify = require('browserify'); var compressAttributes = require('./util/compress_attributes'); -var appendVersion = require('./util/append_version'); var constants = require('./util/constants'); /* @@ -24,10 +23,7 @@ browserify(constants.pathToPlotlySrc, { .bundle(function(err) { if(err) throw err; }) -.pipe(fs.createWriteStream(constants.pathToPlotlyBuild)) -.on('finish', function() { - appendVersion(constants.pathToPlotlyBuild, {object: 'Plotly'}); -}); +.pipe(fs.createWriteStream(constants.pathToPlotlyBuild)); // Browserify the geo assets @@ -37,7 +33,4 @@ browserify(constants.pathToPlotlyGeoAssetsSrc, { .bundle(function(err) { if(err) throw err; }) -.pipe(fs.createWriteStream(constants.pathToPlotlyGeoAssetsDist)) -.on('finish', function() { - appendVersion(constants.pathToPlotlyGeoAssetsDist, {object: 'PlotlyGeoAssets'}); -}); +.pipe(fs.createWriteStream(constants.pathToPlotlyGeoAssetsDist)); diff --git a/tasks/util/append_version.js b/tasks/util/append_version.js deleted file mode 100644 index cc17057e40d..00000000000 --- a/tasks/util/append_version.js +++ /dev/null @@ -1,24 +0,0 @@ -var fs = require('fs'); - -var pkg = require('../../package.json'); - -/** - * Append package version to bundle - * - * @param {string} path path to bundle - * @param {object} opts - * - object {string} the standalone object in the bundle - * - DEV {boolean} is this a DEV build? - */ -module.exports = function appendVersion(path, opts) { - var txt = [ - opts.object, - '.version=', '\'', - pkg.version, opts.DEV ? '-dev' : '', - '\'', ';' - ].join(''); - - fs.appendFile(path, txt, function(err) { - if(err) throw err; - }) ; -}; diff --git a/tasks/util/make_watchified_bundle.js b/tasks/util/make_watchified_bundle.js index 7af73f3bd63..70ae5fadaa4 100644 --- a/tasks/util/make_watchified_bundle.js +++ b/tasks/util/make_watchified_bundle.js @@ -4,7 +4,6 @@ var browserify = require('browserify'); var watchify = require('watchify'); var compressAttributes = require('./compress_attributes'); -var appendVersion = require('./append_version'); var formatBundleMsg = require('./format_bundle_msg'); var constants = require('./constants'); @@ -53,9 +52,6 @@ module.exports = function makeWatchifiedBundle(onFirstBundleCallback) { .pipe( fs.createWriteStream(constants.pathToPlotlyBuild) ) - .on('finish', function() { - appendVersion(constants.pathToPlotlyBuild, {object: 'Plotly', DEV: true}); - }); } return bundle;