Merge pull request #310 from hulkholden/license
[dygraphs.git] / generate-combined.sh
CommitLineData
6a1aa64f
DV
1#!/bin/bash
2# Generates a single JS file that's easier to include.
43f15770 3
1beeb310
KW
4GetSources () {
5 # This list needs to be kept in sync w/ the one in dygraph-dev.js
6 # and the one in jsTestDriver.conf. Order matters, except for the plugins.
7 for F in \
1beeb310
KW
8 dashed-canvas.js \
9 dygraph-options.js \
10 dygraph-layout.js \
11 dygraph-canvas.js \
12 dygraph.js \
13 dygraph-utils.js \
14 dygraph-gviz.js \
15 dygraph-interaction-model.js \
16 dygraph-tickers.js \
17 dygraph-plugin-base.js \
18 plugins/*.js \
a49c164a
DE
19 dygraph-plugin-install.js \
20 datahandler/datahandler.js \
21 datahandler/default.js \
22 datahandler/default-fractions.js \
23 datahandler/bars.js \
24 datahandler/bars-custom.js \
25 datahandler/bars-error.js \
26 datahandler/bars-fractions.js
1beeb310
KW
27 do
28 echo "$F"
29 done
30}
31
74a5af31 32# Pack all the JS together.
1beeb310
KW
33CatSources () {
34 GetSources \
35 | xargs cat \
36 | perl -ne 'print unless m,REMOVE_FOR_COMBINED,..m,/REMOVE_FOR_COMBINED,'
37}
74a5af31 38
1beeb310 39Copyright () {
d218710c 40 echo '/*! @license Copyright 2014 Dan Vanderkam (danvdk@gmail.com) MIT-licensed (http://opensource.org/licenses/MIT) */'
1beeb310 41}
b2a516b8 42
1beeb310
KW
43CatCompressed () {
44 Copyright
45 CatSources \
d218710c 46 | grep -v '"use strict";' \
170b6547 47 | node_modules/uglify-js/bin/uglifyjs -c warnings=false -m
1beeb310 48}
b2a516b8 49
1beeb310
KW
50ACTION="${1:-update}"
51case "$ACTION" in
52ls)
53 GetSources
54 ;;
55cat)
56 Copyright
57 CatSources
58 ;;
59compress*|cat_compress*)
60 CatCompressed
61 ;;
62update)
806e1ea5
DV
63 CatCompressed > dygraph-combined.js
64 chmod a+r dygraph-combined.js
1beeb310
KW
65 ;;
66*)
67 echo >&2 "Unknown action '$ACTION'"
68 exit 1
69 ;;
70esac