forked from maxwellito/vivus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
75 lines (69 loc) · 1.71 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
var gulp = require('gulp'),
gulpImports = require('gulp-imports'),
gutil = require('gulp-util'),
header = require('gulp-header'),
uglify = require('gulp-uglify'),
concat = require('gulp-concat'),
jshint = require('gulp-jshint'),
karma = require('gulp-karma'),
pkg = require('./package.json'),
banner = ['/**',
' * <%= pkg.name %> - <%= pkg.description %>',
' * @version v<%= pkg.version %>',
' * @link <%= pkg.homepage %>',
' * @license <%= pkg.license %>',
' */',
'',
''].join('\n');
/**
* distrib
* Build the final scripts: `vivus.js` and `vivus.min.js`
*
*/
gulp.task('distrib', function () {
gulp.src('./src/_build.js')
.pipe(header(banner, { pkg : pkg } ))
.pipe(gulpImports())
.pipe(concat('vivus.js'))
.pipe(gulp.dest('./dist'))
.pipe(concat('vivus.min.js'))
.pipe(uglify({preserveComments: 'some'}))
.pipe(gulp.dest('./dist'));
});
/**
* lint
* run JShint on the scripts
*
*/
gulp.task('lint', function () {
return gulp.src(['src/pathformer.js', 'src/vivus.js'])
.pipe(jshint())
.pipe(jshint.reporter('default'));
});
/**
* test
* run Karma on the scripts
*
*/
gulp.task('test', function () {
// Be sure to return the stream
return gulp.src(['src/pathformer.js', 'src/vivus.js', 'test/unit/**.js'])
.pipe(karma({
configFile: 'test/karma.conf.js',
action: 'run'
}));
});
/**
* develop
* Task to develop, it run a watch which pass JShint and build
* the final scripts.
*
*/
gulp.task('develop', function () {
gulp.watch('./src/*', function () {
gulp.run('lint', 'test', 'distrib');
});
gulp.watch('./test/**/*.spec.js', function () {
gulp.run('test');
});
});