REFACTORING: fixed jslint violation
[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 do
24 echo "$F"
25 done
26}
27
28# Pack all the JS together.
29CatSources () {
30 GetSources \
31 | xargs cat \
32 | perl -ne 'print unless m,REMOVE_FOR_COMBINED,..m,/REMOVE_FOR_COMBINED,'
33}
34
35Copyright () {
36 echo '/*! @license Copyright 2011 Dan Vanderkam (danvdk@gmail.com) MIT-licensed (http://opensource.org/licenses/MIT) */'
37}
38
39CatCompressed () {
40 Copyright
41 CatSources \
42 | java -jar yuicompressor-2.4.2.jar --type js
43}
44
45ACTION="${1:-update}"
46case "$ACTION" in
47ls)
48 GetSources
49 ;;
50cat)
51 Copyright
52 CatSources
53 ;;
54compress*|cat_compress*)
55 CatCompressed
56 ;;
57update)
58 CatCompressed > dygraph-combined.js
59 chmod a+r dygraph-combined.js
60 ;;
61*)
62 echo >&2 "Unknown action '$ACTION'"
63 exit 1
64 ;;
65esac