Skip to content

Commit 71765f1

Browse files
committed
Merge pull request #35 from plotly/licence-headers
Add 'header' build task
2 parents 0dff67a + a1919ce commit 71765f1

File tree

3 files changed

+39
-4
lines changed

3 files changed

+39
-4
lines changed

package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
"preprocess": "node tasks/preprocess.js",
2424
"postinstall": "npm run preprocess",
2525
"bundle": "node tasks/bundle.js",
26-
"build": "npm run preprocess && npm run bundle",
26+
"header": "node tasks/header.js",
27+
"build": "npm run preprocess && npm run bundle && npm run header",
2728
"cibuild": "node tasks/cibundle.js",
2829
"watch": "node tasks/watch_plotly.js",
2930
"lint": "cd src && jshint . || true",
@@ -90,9 +91,10 @@
9091
"karma-firefox-launcher": "^0.1.6",
9192
"karma-jasmine": "^0.3.6",
9293
"open": "0.0.5",
94+
"prepend-file": "^1.3.0",
9395
"prettysize": "0.0.3",
9496
"through2": "^2.0.0",
95-
"watchify": "^3.6.0",
96-
"uglify-js": "^2.5.0"
97+
"uglify-js": "^2.5.0",
98+
"watchify": "^3.6.0"
9799
}
98100
}

tasks/header.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
var prependFile = require('prepend-file');
2+
3+
var constants = require('./util/constants');
4+
5+
6+
// add headers to dist files
7+
8+
var pathsDist = [
9+
constants.pathToPlotlyDistMin,
10+
constants.pathToPlotlyDist,
11+
constants.pathToPlotlyDistWithMeta,
12+
constants.pathToPlotlyGeoAssetsDist
13+
];
14+
15+
function headerLicense(path) {
16+
prependFile(path, constants.licenseDist, function(err) {
17+
if(err) throw err;
18+
});
19+
}
20+
21+
pathsDist.forEach(headerLicense);

tasks/util/constants.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
var fs = require('fs');
22
var path = require('path');
33

4+
var pkg = require('../../package.json');
5+
46
var pathToRoot = path.join(__dirname, '../../');
57
var pathToRootParent = path.join(__dirname, '../../../../');
68
var pathToSrc = path.join(pathToRoot, 'src/');
@@ -61,5 +63,15 @@ module.exports = {
6163
beautify: false,
6264
ascii_only: true
6365
}
64-
}
66+
},
67+
68+
licenseDist: [
69+
'/**',
70+
'* plotly.js v' + pkg.version,
71+
'* Copyright 2012-2015, Plotly, Inc.',
72+
'* All rights reserved.',
73+
'* Licensed under the MIT license',
74+
'*/',
75+
''
76+
].join('\n')
6577
};

0 commit comments

Comments
 (0)