forked from shrimalmadhur/uvCharts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
111 lines (97 loc) · 3.2 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
var gulp = require('gulp'),
sourcemaps = require('gulp-sourcemaps'),
concat = require('gulp-concat'),
uglify = require('gulp-uglify'),
watch = require('gulp-watch'),
zip = require('gulp-zip'),
bower = require('gulp-bower'),
jshint = require('gulp-jshint'),
eclint = require('eclint'),
del = require('del'),
stylish = require('jshint-stylish'),
bower = require('gulp-bower'),
webserver = require('gulp-webserver'),
packageInfo = require('./package.json');
var paths = {
"module_begin": ['src/module/module_begin.js'],
"util": ['src/util/utility.js', 'src/util/config.js', 'src/util/constants.js', 'src/util/register.js', 'src/util/effects.js', 'src/util/palette.js'],
"gfx": ['src/gfx/graph.js', 'src/gfx/*.js'],
"module_end": ['src/module/module_end.js'],
"test": ['src/util/test.js'],
"release_assets": ['build/uvcharts*.js'],
"d3_min_src": ["bower_components/d3/d3.js"]
};
gulp.task('clean:dev', function (cb) {
del(['build/*'], cb);
});
gulp.task('clean:gfx', function (cb) {
del(['build/uvcharts*.js'], cb);
});
gulp.task('clean:test', function (cb) {
del(['build/uvtest*.js'], cb);
});
gulp.task('clean:all', function (cb) {
del(['build/*', 'dist/*'], cb);
});
gulp.task('bower', function () {
return bower();
});
gulp.task('build:gfx', ['clean:gfx'], function () {
return gulp.src(paths['module_begin'].concat(paths.util).concat(paths.gfx).concat(paths['module_end']))
.pipe(sourcemaps.init())
.pipe(concat('uvcharts.js'))
.pipe(jshint())
.pipe(jshint.reporter(stylish))
/*.pipe(eclint.check({
reporter: function(file, message) {
console.error(path.relative('.', file.path) + ':', message);
}
}))*/
.pipe(gulp.dest('build/'))
.pipe(uglify())
.pipe(concat('uvcharts.min.js'))
.pipe(gulp.dest('build/'));
});
gulp.task('build:full:gfx', ['bower', 'clean:gfx'], function () {
return gulp.src(paths['d3_min_src'].concat(paths['module_begin']).concat(paths.util).concat(paths.gfx).concat(paths['module_end']))
.pipe(sourcemaps.init())
.pipe(concat('uvcharts.full.js'))
.pipe(gulp.dest('build/'))
.pipe(uglify())
.pipe(concat('uvcharts.full.min.js'))
.pipe(gulp.dest('build/'));
});
gulp.task('build:test', ['clean:test'], function () {
return gulp.src(paths.test)
.pipe(sourcemaps.init())
.pipe(concat('uvtest.js'))
.pipe(jshint())
.pipe(jshint.reporter(stylish))
.pipe(gulp.dest('build/'))
.pipe(uglify())
.pipe(concat('uvtest.min.js'))
.pipe(gulp.dest('build/'));
});
gulp.task('release:gfx', ['build:gfx', 'build:full:gfx'], function () {
return gulp.src(paths["release_assets"])
.pipe(zip("uvcharts-" + packageInfo.version + ".zip"))
.pipe(gulp.dest('dist'));
});
gulp.task('watch:gfx', ['build:gfx', 'serve:test'], function () {
return gulp.watch(paths['gfx'].concat(paths['util']), ['build:gfx']);
});
gulp.task('deps:get', function () {
return bower().pipe(gulp.dest('lib/'));
});
gulp.task('serve:test', function () {
gulp.src('.')
.pipe(webserver({
port: 9090,
livereload: true,
directoryListing: true,
open: true,
path: "/",
open: "/test/gfx/simple_test.html"
}));
})
gulp.task('default', ['build:gfx', 'build:test']);