-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgulpfile.js
More file actions
94 lines (80 loc) · 2.57 KB
/
gulpfile.js
File metadata and controls
94 lines (80 loc) · 2.57 KB
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
var fs = require('fs'),
path = require('path'),
gulp = require('gulp'),
jshint = require('gulp-jshint'),
concat = require('gulp-concat'),
uglify = require('gulp-uglify'),
mocha = require('gulp-mocha'),
header = require('gulp-header'),
rimraf = require('gulp-rimraf'),
pkg = JSON.parse(
fs.readFileSync(path.resolve(__dirname, './package.json'))
),
banner = ['/**',
' * Copyright (c) <%= new Date().getFullYear() %>',
' * <%= pkg.name %> - <%= pkg.description %>',
' * Built on <%= (new Date).toISOString().slice(0,10) %>',
' * ',
' * @version <%= pkg.version %>',
' * @link <%= pkg.repository.url %>',
' * @license <%= pkg.license %>',
' */',
''].join('\n') + '\n';
gulp.task('jshint:dev', function() {
gulp.src(['gulpfile.js', 'tests/**/*.js'])
.pipe(jshint({
maxlen: 80,
quotmark: 'single'
}))
.pipe(jshint.reporter('default'));
});
gulp.task('jshint:app', function () {
gulp.src(['src/*.js'])
.pipe(jshint({
maxlen: 80,
quotmark: 'single'
}))
.pipe(jshint.reporter('default'));
});
gulp.task('test', function() {
gulp.src(['test/**/*.js'])
.pipe(mocha());
});
gulp.task('copy', function() {
gulp.src(['node_modules/mocha/mocha.js'])
.pipe(gulp.dest('public/assets/js'));
gulp.src(['node_modules/mocha/mocha.css'])
.pipe(gulp.dest('public/assets/css'));
gulp.src(['node_modules/chai/chai.js'])
.pipe(gulp.dest('public/assets/js'));
gulp.src(['node_modules/sinon/pkg/sinon.js'])
.pipe(gulp.dest('public/assets/js'));
gulp.src(['node_modules/jquery/dist/jquery.js'])
.pipe(gulp.dest('public/assets/js'));
});
gulp.task('concat', function () {
gulp.src(['src/*.js'])
.pipe(concat(pkg.name + '.js'))
.pipe(header(banner, { pkg: pkg }))
.pipe(gulp.dest('dist'));
});
gulp.task('uglify', function() {
gulp.src(['src/*.js'])
.pipe(uglify())
.pipe(header(banner, { pkg: pkg }))
.pipe(concat(pkg.name + '.min.js'))
.pipe(gulp.dest('dist'));
});
gulp.task('clean', function() {
gulp.src('dist', { read: false }) // much faster
.pipe(rimraf());
});
gulp.task('watch', function () {
gulp.watch(
['gruntfile.js', 'src/*.js', 'tests/**/*.js'],
['jshint:dev', 'jshint:app', 'test']
);
});
gulp.task('build', ['concat', 'uglify']);
gulp.task('default', ['jshint:dev', 'jshint:app', 'test', 'copy', 'concat',
'uglify']);