Merge
[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 \
a14ed8aa 8 polyfills/console.js \
1beeb310
KW
9 dashed-canvas.js \
10 dygraph-options.js \
11 dygraph-layout.js \
12 dygraph-canvas.js \
13 dygraph.js \
14 dygraph-utils.js \
15 dygraph-gviz.js \
16 dygraph-interaction-model.js \
17 dygraph-tickers.js \
18 dygraph-plugin-base.js \
19 plugins/*.js \
a49c164a
DE
20 dygraph-plugin-install.js \
21 datahandler/datahandler.js \
22 datahandler/default.js \
23 datahandler/default-fractions.js \
24 datahandler/bars.js \
25 datahandler/bars-custom.js \
26 datahandler/bars-error.js \
27 datahandler/bars-fractions.js
1beeb310
KW
28 do
29 echo "$F"
30 done
31}
32
74a5af31 33# Pack all the JS together.
1beeb310
KW
34CatSources () {
35 GetSources \
103fd879 36 | xargs cat
1beeb310 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 43CatCompressed () {
103fd879
DV
44 node_modules/uglify-js/bin/uglifyjs \
45 $(GetSources | xargs) \
46 --compress warnings=false \
47 --mangle \
48 --define DEBUG=false \
49 --preamble "$(Copyright)" \
50 $*
1beeb310 51}
b2a516b8 52
1beeb310
KW
53ACTION="${1:-update}"
54case "$ACTION" in
55ls)
56 GetSources
57 ;;
58cat)
59 Copyright
60 CatSources
61 ;;
62compress*|cat_compress*)
63 CatCompressed
64 ;;
65update)
103fd879
DV
66 CatCompressed --source-map dygraph-combined.js.map \
67 > dygraph-combined.js
68 chmod a+r dygraph-combined.js dygraph-combined.js.map
1beeb310
KW
69 ;;
70*)
71 echo >&2 "Unknown action '$ACTION'"
72 exit 1
73 ;;
74esac