Skip to content

Commit f95f9aa

Browse files
committed
tasks: add partial bundle name to dist headers
1 parent 9bead06 commit f95f9aa

File tree

1 file changed

+26
-16
lines changed

1 file changed

+26
-16
lines changed

tasks/header.js

+26-16
Original file line numberDiff line numberDiff line change
@@ -7,35 +7,45 @@ var glob = require('glob');
77

88
var constants = require('./util/constants');
99

10+
// main
11+
addHeadersInDistFiles();
1012
updateHeadersInSrcFiles();
1113

1214
// add headers to dist files
15+
function addHeadersInDistFiles() {
16+
function _prepend(path, header) {
17+
prependFile(path, header + '\n', function(err) {
18+
if(err) throw err;
19+
});
20+
}
1321

14-
var pathsDist = [
15-
constants.pathToPlotlyDistMin,
16-
constants.pathToPlotlyDist,
17-
constants.pathToPlotlyDistWithMeta,
18-
constants.pathToPlotlyGeoAssetsDist
19-
];
20-
21-
constants.partialBundleNames.forEach(function(name) {
22-
var pathToBundle = path.join(constants.pathToDist, 'plotly-' + name + '.js'),
23-
pathToMinBundle = path.join(constants.pathToDist, 'plotly-' + name + '.min.js');
22+
// add header to main dist bundles
23+
var pathsDist = [
24+
constants.pathToPlotlyDistMin,
25+
constants.pathToPlotlyDist,
26+
constants.pathToPlotlyDistWithMeta,
27+
constants.pathToPlotlyGeoAssetsDist
28+
];
29+
pathsDist.forEach(function(path) {
30+
_prepend(path, constants.licenseDist);
31+
});
2432

25-
pathsDist.push(pathToBundle, pathToMinBundle);
26-
});
33+
// add header and bundle name to partial bundle
34+
constants.partialBundlePaths.forEach(function(pathObj) {
35+
var headerDist = constants.licenseDist
36+
.replace('plotly.js', 'plotly.js (' + pathObj.name + ')');
37+
_prepend(pathObj.dist, headerDist);
2738

28-
function headerLicense(path) {
29-
prependFile(path, constants.licenseDist + '\n', function(err) {
30-
if(err) throw err;
39+
var headerDistMin = constants.licenseDist
40+
.replace('plotly.js', 'plotly.js (' + pathObj.name + ' - minified)');
41+
_prepend(pathObj.distMin, headerDistMin);
3142
});
3243
}
3344

3445
// add or update header to src/ lib/ files
3546
function updateHeadersInSrcFiles() {
3647
var srcGlob = path.join(constants.pathToSrc, '**/*.js');
3748
var libGlob = path.join(constants.pathToLib, '**/*.js');
38-
pathsDist.forEach(headerLicense);
3949

4050
// remove leading '/*' and trailing '*/' for comparison with falafel output
4151
var licenseSrc = constants.licenseSrc;

0 commit comments

Comments
 (0)