Merge pull request #240 from timeu/bugfix_upstream
[dygraphs.git] / generate-combined.sh
1 #!/bin/bash
2 # Generates a single JS file that's easier to include.
3
4 GetSources () {
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 \
8 strftime/strftime-min.js \
9 rgbcolor/rgbcolor.js \
10 stacktrace.js \
11 dashed-canvas.js \
12 dygraph-options.js \
13 dygraph-layout.js \
14 dygraph-canvas.js \
15 dygraph.js \
16 dygraph-utils.js \
17 dygraph-gviz.js \
18 dygraph-interaction-model.js \
19 dygraph-tickers.js \
20 dygraph-plugin-base.js \
21 plugins/*.js \
22 dygraph-plugin-install.js
23 do
24 echo "$F"
25 done
26 }
27
28 # Pack all the JS together.
29 CatSources () {
30 GetSources \
31 | xargs cat \
32 | perl -ne 'print unless m,REMOVE_FOR_COMBINED,..m,/REMOVE_FOR_COMBINED,'
33 }
34
35 Copyright () {
36 echo '/*! @license Copyright 2011 Dan Vanderkam (danvdk@gmail.com) MIT-licensed (http://opensource.org/licenses/MIT) */'
37 }
38
39 CatCompressed () {
40 Copyright
41 CatSources \
42 | java -jar yuicompressor-2.4.2.jar --type js
43 }
44
45 ACTION="${1:-update}"
46 case "$ACTION" in
47 ls)
48 GetSources
49 ;;
50 cat)
51 Copyright
52 CatSources
53 ;;
54 compress*|cat_compress*)
55 CatCompressed
56 ;;
57 update)
58 CatCompressed > dygraph-combined.js
59 chmod a+r dygraph-combined.js
60 ;;
61 *)
62 echo >&2 "Unknown action '$ACTION'"
63 exit 1
64 ;;
65 esac