-
Notifications
You must be signed in to change notification settings - Fork 505
/
gulpfile.js
78 lines (69 loc) · 1.9 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
'use strict';
var gulp = require('gulp'),
fs = require('fs'),
path = require('path'),
plugins = require('gulp-load-plugins')(),
getFolders = function(dir){
return fs.readdirSync(dir)
.filter(function(file) {
return fs.statSync(path.join(dir, file)).isDirectory();
});
};
var
scripts = [
'./src/**/*.js'
],
demos = [
'./demos/anchor-transitions/assets/js',
'./demos/barebones/assets/js',
'./demos/csstricks/assets/js',
'./demos/sidebar/assets/js'
],
tests = [
'./tests/**/*.js'
],
srcScripts = scripts.concat(tests),
demoScripts = [ './jquery.smoothState.min.js' ];
/** Serve demos for testing */
gulp.task('serve', [ 'copyDemoFiles' ], function() {
gulp.src('demos')
.pipe(plugins.webserver({
open: true
}));
});
/** Run all unit tests */
gulp.task('test', function() {
return gulp.src('./tests/index.html')
.pipe(plugins.qunit());
});
/** Run all unit tests */
gulp.task('copyDemoFiles', function() {
return gulp.src(demoScripts)
.pipe(gulp.dest(demos[0]))
.pipe(gulp.dest(demos[1]))
.pipe(gulp.dest(demos[2]))
.pipe(gulp.dest(demos[3]));
});
/** Lint JavaScript */
gulp.task('jshint', function () {
return gulp.src(srcScripts)
.pipe(plugins.jshint())
.pipe(plugins.jshint.reporter('jshint-stylish'))
.pipe(plugins.jshint.reporter('fail'));
});
/** Concatenate and minify JavaScript */
gulp.task('uglify', function () {
return gulp.src(scripts)
.pipe(plugins.concat('jquery.smoothState.min.js'))
.pipe(plugins.uglify({ preserveComments: 'some' }))
.pipe(gulp.dest('./'))
.pipe(plugins.size({ title: 'scripts' }));
});
/** Watch changes */
gulp.task('watch', function() {
gulp.watch(srcScripts, [ 'jshint', 'test', 'uglify', 'copyDemoFiles' ]);
});
/** Default task */
gulp.task('default', [ 'jshint', 'test' ], function() {
gulp.start('uglify');
});