Merge branch 'release-1.0.1'
[dygraphs.git] / generate-combined.sh
... / ...
CommitLineData
1#!/bin/bash
2# Generates a single JS file that's easier to include.
3
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 \
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 datahandler/datahandler.js \
24 datahandler/default.js \
25 datahandler/default-fractions.js \
26 datahandler/bars.js \
27 datahandler/bars-custom.js \
28 datahandler/bars-error.js \
29 datahandler/bars-fractions.js
30 do
31 echo "$F"
32 done
33}
34
35# Pack all the JS together.
36CatSources () {
37 GetSources \
38 | xargs cat \
39 | perl -ne 'print unless m,REMOVE_FOR_COMBINED,..m,/REMOVE_FOR_COMBINED,'
40}
41
42Copyright () {
43 echo '/*! @license Copyright 2011 Dan Vanderkam (danvdk@gmail.com) MIT-licensed (http://opensource.org/licenses/MIT) */'
44}
45
46CatCompressed () {
47 Copyright
48 CatSources \
49 | java -jar yuicompressor-2.4.2.jar --type js
50}
51
52ACTION="${1:-update}"
53case "$ACTION" in
54ls)
55 GetSources
56 ;;
57cat)
58 Copyright
59 CatSources
60 ;;
61compress*|cat_compress*)
62 CatCompressed
63 ;;
64update)
65 CatCompressed > dygraph-combined.js
66 chmod a+r dygraph-combined.js
67 ;;
68*)
69 echo >&2 "Unknown action '$ACTION'"
70 exit 1
71 ;;
72esac