Merge pull request #484 from danvk/wrapped-labels
[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 4GetSources () {
d85ec732
DV
5 # Include dyraph-options-reference only if DEBUG environment variable is set.
6 if [ ! -z "$DEBUG" ]; then
7 maybe_options_reference=dygraph-options-reference.js
8 else
9 maybe_options_reference=''
10 fi
11
1beeb310
KW
12 # This list needs to be kept in sync w/ the one in dygraph-dev.js
13 # and the one in jsTestDriver.conf. Order matters, except for the plugins.
14 for F in \
a14ed8aa 15 polyfills/console.js \
1beeb310
KW
16 dashed-canvas.js \
17 dygraph-options.js \
18 dygraph-layout.js \
19 dygraph-canvas.js \
20 dygraph.js \
21 dygraph-utils.js \
22 dygraph-gviz.js \
23 dygraph-interaction-model.js \
24 dygraph-tickers.js \
25 dygraph-plugin-base.js \
26 plugins/*.js \
a49c164a 27 dygraph-plugin-install.js \
d85ec732 28 $maybe_options_reference \
a49c164a
DE
29 datahandler/datahandler.js \
30 datahandler/default.js \
31 datahandler/default-fractions.js \
32 datahandler/bars.js \
33 datahandler/bars-custom.js \
34 datahandler/bars-error.js \
35 datahandler/bars-fractions.js
1beeb310
KW
36 do
37 echo "$F"
38 done
39}
40
74a5af31 41# Pack all the JS together.
1beeb310
KW
42CatSources () {
43 GetSources \
103fd879 44 | xargs cat
1beeb310 45}
74a5af31 46
1beeb310 47Copyright () {
d218710c 48 echo '/*! @license Copyright 2014 Dan Vanderkam (danvdk@gmail.com) MIT-licensed (http://opensource.org/licenses/MIT) */'
1beeb310 49}
b2a516b8 50
1beeb310 51CatCompressed () {
103fd879
DV
52 node_modules/uglify-js/bin/uglifyjs \
53 $(GetSources | xargs) \
54 --compress warnings=false \
55 --mangle \
56 --define DEBUG=false \
57 --preamble "$(Copyright)" \
58 $*
1beeb310 59}
b2a516b8 60
1beeb310
KW
61ACTION="${1:-update}"
62case "$ACTION" in
63ls)
64 GetSources
65 ;;
66cat)
67 Copyright
68 CatSources
69 ;;
d85ec732
DV
70cat-dev)
71 DEBUG=true
72 Copyright
73 CatSources
74 ;;
1beeb310
KW
75compress*|cat_compress*)
76 CatCompressed
77 ;;
78update)
103fd879
DV
79 CatCompressed --source-map dygraph-combined.js.map \
80 > dygraph-combined.js
81 chmod a+r dygraph-combined.js dygraph-combined.js.map
1beeb310
KW
82 ;;
83*)
84 echo >&2 "Unknown action '$ACTION'"
85 exit 1
86 ;;
87esac