-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gulpfile.js
91 lines (80 loc) · 2.29 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
79
80
81
82
83
84
85
86
87
88
89
90
91
'use strict';
var fs = require('fs');
var pkg = JSON.parse( fs.readFileSync('./package.json') );
var gulp = require('gulp');
var sourcemaps = require('gulp-sourcemaps');
var plugins = require('gulp-load-plugins')();
var gutil = require('gulp-util');
var qunit = require('gulp-qunit');
var shell = require('gulp-shell');
var merge = require('merge-stream');
var size = require('gulp-check-filesize');
var jshint = require('gulp-jshint');
var rename = require('gulp-rename');
var insert = require('gulp-insert');
var build = {
filename: 'rekord-session.js',
minified: 'rekord-session.min.js',
output: './build/',
include: [
'./src/header.js',
'./src/lib/**/*.js',
'./src/footer.js'
]
};
var comments = [
"/*", pkg.name, pkg.version, '-', pkg.description, 'by', pkg.author, "*/\n"
];
var executeMinifiedBuild = function(props)
{
return function() {
return gulp
.src( props.output + props.filename )
.pipe( rename( props.minified ) )
.pipe( sourcemaps.init() )
.pipe( plugins.uglify().on('error', gutil.log) )
.pipe( insert.prepend( comments.join(' ') ) )
.pipe( sourcemaps.write('.') )
.pipe( size({enableGzip: true}) )
.pipe( gulp.dest( props.output ) )
;
};
};
var executeBuild = function(props)
{
return function() {
return gulp
.src( props.include )
.pipe( plugins.concat( props.filename ) )
.pipe( insert.prepend( comments.join(' ') ) )
.pipe( size({enableGzip: true}) )
.pipe( gulp.dest( props.output ) )
.pipe( jshint() )
.pipe( jshint.reporter('default') )
.pipe( jshint.reporter('fail') )
;
};
};
var executeTest = function(file)
{
return function() {
return gulp
.src( file )
.pipe( qunit() )
;
};
};
gulp.task('lint', function() {
return gulp
.src( build.output + build.filename )
.pipe( jshint() )
.pipe( jshint.reporter('default') )
.pipe( jshint.reporter('fail') )
;
});
gulp.task( 'js', executeBuild( build ) );
gulp.task( 'js:min', ['js'], executeMinifiedBuild( build ) );
gulp.task( 'default', ['js:min']);
gulp.task( 'test', ['js'], executeTest( './test/index.html' ) );
gulp.task( 'docs', shell.task(['./node_modules/.bin/jsdoc -c jsdoc.json']));
gulp.task( 'clean', shell.task(['rm -rf build/*.js', 'rm -rf build/*.map']));