09b636fc60a5ecb8f027676b499b9307003d0444
1 var gulp
= require('gulp');
2 var plugins
= require('gulp-load-plugins')();
3 var karma
= require('karma').server
;
4 var lazypipe
= require('lazypipe');
5 var path
= require('path');
26 "dygraph-interaction-model.js",
28 "dygraph-plugin-base.js"
32 base
: "src/dygraph/plugins",
40 "../dygraph-plugin-install.js"
43 // Only used by dynamic loader
46 files
: ["dygraph-options-reference.js"]
49 base
: "src/dygraph/datahandler",
53 "default-fractions.js",
62 // Convenience function to merge multiple arrays into one
63 var mergePaths
= function() {
66 if (arguments
.length
> 0) {
67 for (var i
= 0; i
< arguments
.length
; i
++) {
68 pathObj
= arguments
[i
];
69 pathObj
.files
.map(function(filename
) {
70 paths
.push(path
.join(pathObj
.base
, filename
));
80 var copyright
= '/*! @license Copyright 2014 Dan Vanderkam (danvdk@gmail.com) MIT-licensed (http://opensource.org/licenses/MIT) */';
82 // Creates the dygraph-autoloader
83 gulp
.task('create-loader', function() {
84 // Create string ready for javascript array
85 var files
= mergePaths(src
.lib
, src
.main
, src
.plugins
, src
.devOptions
, src
.datahandlers
)
86 .map(function(filename
) {
87 // Make the path relative to dist file and add quotes
88 return "'" + filename
.replace(src
.base
, '../../' + src
.base
) + "'";
92 return gulp
.src(src
.base
+ '/dygraph/dygraph-autoloader.js')
93 .pipe(plugins
.replace(/\/\* REPLACEME
\*\//, files))
94 .pipe(gulp
.dest('dist/scratch'));
97 gulp
.task('create-dev', function() {
98 var dest
= 'dist/scratch';
99 return gulp
.src(mergePaths(src
.lib
, src
.main
, src
.plugins
, src
.devOptions
, src
.datahandlers
))
100 .pipe(plugins
.sourcemaps
.init())
101 .pipe(plugins
.concat('dygraph-combined.dev.js'))
102 .pipe(plugins
.header(copyright
))
103 .pipe(gulp
.dest(dest
));
106 gulp
.task('concat', function() {
107 var dest
= 'dist/scratch';
108 return gulp
.src(mergePaths(src
.lib
, src
.main
, src
.plugins
, src
.datahandlers
))
109 .pipe(plugins
.sourcemaps
.init())
110 .pipe(plugins
.concat('dygraph-combined.js'))
111 .pipe(plugins
.header(copyright
))
112 .pipe(gulp
.dest(dest
))
113 .pipe(plugins
.uglify({
114 define
: "DEBUG=false",
116 preserveComments
: "none"
118 .pipe(plugins
.header(copyright
))
119 .pipe(plugins
.rename('dygraph-combined.min.js'))
120 .pipe(plugins
.sourcemaps
.write('.'))
121 .pipe(gulp
.dest(dest
));
125 gulp
.task("bower-dist", ['concat'], function() {
126 gulp
.src('src/dygraph/extras/**', {base
: 'src/dygraph'})
127 .pipe(gulp
.dest('dist/bower'));
129 return gulp
.src('dist/scratch/dygraph-combined*')
130 .pipe(gulp
.dest('dist/bower'));
133 gulp
.task('gwt-dist', ['concat'], function() {
134 // Copy package structure to dist folder
135 gulp
.src('gwt/**', {'base': '.'})
136 .pipe(gulp
.dest('dist'));
138 gulp
.src('scratch/dygraph-combined.min.js')
139 .pipe(gulp
.dest('dist/gwt/org/danvk'));
143 .pipe(plugins
.shell([
144 'bash -c "jar -cf dygraph-gwt.jar -C dist/gwt org"'
148 gulp
.task('test', ['concat', 'create-dev'], function(done
) {
150 configFile
: process
.cwd() + '/specs/karma.conf.js',
155 gulp
.task('watch', function() {
156 gulp
.watch('src/dygraph/**', ['concat']);
159 gulp
.task('watch-test', function() {
160 gulp
.watch(['src/dygraph/**', 'specs/unit/**'], ['test']);
163 gulp
.task('dist', ['gwt-dist', 'bower-dist']);
164 gulp
.task('travis', ['test']);
165 gulp
.task('default', ['test', 'dist']);