forked from nusmodifications/nusmods
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
71 lines (60 loc) · 1.78 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
/* eslint-disable prefer-arrow-callback, func-names, strict */
'use strict';
// # Globbing
// for performance reasons we're only matching one level down:
// 'test/spec/{,*/}*.js'
// use this if you want to recursively match all subfolders:
// 'test/spec/**/*.js'
// Relevant folders:
// .tmp/ (holding area)
// dist/ (final distributed app)
// Phase 1: Clean up (clean)
// Phase 2: Copy files from app, vendor to .tmp or to dist/ (copy)
// Phase 3: Run minification (imagemin, svgmin)
// Phase 4: webpack to bundle app main.js
const gulp = require('gulp');
const plugins = require('gulp-load-plugins')();
const del = require('del');
const stylish = require('jshint-stylish');
// const webpack = require('webpack-stream');
// Mocha testing framework configuration options
gulp.task('test', function() {
return gulp.src(['test/*.js'], { read: false })
.pipe(plugins.mocha());
});
gulp.task('rsync', function() {
gulp.src('dist')
.pipe(plugins.rsync({
root: 'dist',
destination: '../nusmods.com',
recursive: true,
update: true
}));
});
// Empties folders to start fresh
gulp.task('clean', function() {
del.sync(['dist/*', '!dist/.git*']);
});
// Make sure code styles are up to par and there are no obvious mistakes
gulp.task('jshint', function() {
return gulp.src([
'gulpfile.js',
'app/scripts/**/*.js',
'!app/scripts/vendor/*',
'test/spec/{,*/}*.js'])
.pipe(plugins.jshint())
.pipe(plugins.jshint.reporter(stylish));
});
gulp.task('eslint', function() {
return gulp.src([
'gulpfile.js',
'webpack.config.js',
'app/scripts/**/*.js',
'test/spec/{,*/}*.js',
'!app/scripts/vendor/*',
'!node_modules/**/*.js',
])
.pipe(plugins.eslint())
.pipe(plugins.eslint.format());
});
gulp.task('default', ['jshint', 'test'])