This repository has been archived by the owner on Sep 6, 2020. It is now read-only.
forked from miguel-perez/smoothState.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
74 lines (65 loc) · 1.74 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
'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/barebones',
'./demos/csstricks',
],
tests = [
'./tests/**/*.js'
],
allScripts = scripts.concat(tests),
demoScripts = scripts.concat('./node_modules/jquery/dist/jquery.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]));
});
/** Lint JavaScript */
gulp.task('jshint', function () {
return gulp.src(allScripts)
.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(allScripts, ['jshint', 'test', 'copyDemoFiles']);
});
/** Default task */
gulp.task('default', ['jshint', 'test'], function() {
gulp.start('uglify');
});