diff --git a/package.json b/package.json index 8eee58bff43..ecb24419316 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,8 @@ "preprocess": "node tasks/preprocess.js", "postinstall": "npm run preprocess", "bundle": "node tasks/bundle.js", - "build": "npm run preprocess && npm run bundle", + "header": "node tasks/header.js", + "build": "npm run preprocess && npm run bundle && npm run header", "cibuild": "node tasks/cibundle.js", "watch": "node tasks/watch_plotly.js", "lint": "cd src && jshint . || true", @@ -90,9 +91,10 @@ "karma-firefox-launcher": "^0.1.6", "karma-jasmine": "^0.3.6", "open": "0.0.5", + "prepend-file": "^1.3.0", "prettysize": "0.0.3", "through2": "^2.0.0", - "watchify": "^3.6.0", - "uglify-js": "^2.5.0" + "uglify-js": "^2.5.0", + "watchify": "^3.6.0" } } diff --git a/tasks/header.js b/tasks/header.js new file mode 100644 index 00000000000..14792f21f8e --- /dev/null +++ b/tasks/header.js @@ -0,0 +1,21 @@ +var prependFile = require('prepend-file'); + +var constants = require('./util/constants'); + + +// add headers to dist files + +var pathsDist = [ + constants.pathToPlotlyDistMin, + constants.pathToPlotlyDist, + constants.pathToPlotlyDistWithMeta, + constants.pathToPlotlyGeoAssetsDist +]; + +function headerLicense(path) { + prependFile(path, constants.licenseDist, function(err) { + if(err) throw err; + }); +} + +pathsDist.forEach(headerLicense); diff --git a/tasks/util/constants.js b/tasks/util/constants.js index edf7255d5a9..f27502834df 100644 --- a/tasks/util/constants.js +++ b/tasks/util/constants.js @@ -1,6 +1,8 @@ var fs = require('fs'); var path = require('path'); +var pkg = require('../../package.json'); + var pathToRoot = path.join(__dirname, '../../'); var pathToRootParent = path.join(__dirname, '../../../../'); var pathToSrc = path.join(pathToRoot, 'src/'); @@ -61,5 +63,15 @@ module.exports = { beautify: false, ascii_only: true } - } + }, + + licenseDist: [ + '/**', + '* plotly.js v' + pkg.version, + '* Copyright 2012-2015, Plotly, Inc.', + '* All rights reserved.', + '* Licensed under the MIT license', + '*/', + '' + ].join('\n') };