This repository has been archived by the owner on Dec 18, 2018. It is now read-only.
forked from eface2face/rtcninja.js
-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
75 lines (63 loc) · 1.89 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
'use strict';
var browserify = require('browserify'),
vinyl_source_stream = require('vinyl-source-stream'),
gulp = require('gulp'),
jshint = require('gulp-jshint'),
jscs = require('gulp-jscs'),
stylish = require('gulp-jscs-stylish'),
uglify = require('gulp-uglify'),
rename = require('gulp-rename'),
filelog = require('gulp-filelog'),
header = require('gulp-header'),
expect = require('gulp-expect-file'),
fs = require('fs'),
path = require('path'),
PKG_INFO = require('./package.json'),
// Build filenames.
BUILDS = {
uncompressed: PKG_INFO.name + '.js',
compressed: PKG_INFO.name + '.min.js'
},
// gulp-header.
BANNER = fs.readFileSync('banner.txt').toString(),
BANNER_OPTS = {
pkg: PKG_INFO,
currentYear: (new Date()).getFullYear()
},
// gulp-expect-file options.
EXPECT_OPTS = {
silent: true,
errorOnFailure: true,
checkRealFile: true
},
JS_FILES = ['gulpfile.js', 'lib/*.js'];
gulp.task('lint', function () {
return gulp.src(JS_FILES)
.pipe(jshint()) // enforce good practics
.pipe(jscs()) // enforce style guide
.pipe(stylish.combineWithHintResults())
.pipe(jshint.reporter('jshint-stylish'));
});
gulp.task('browserify', function () {
return browserify([path.join(__dirname, PKG_INFO.main)], {
standalone: PKG_INFO.name
}).bundle()
.pipe(vinyl_source_stream(PKG_INFO.name + '.js'))
.pipe(filelog('browserify'))
.pipe(header(BANNER, BANNER_OPTS))
.pipe(rename(BUILDS.uncompressed))
.pipe(gulp.dest('dist/'));
});
gulp.task('uglify', function () {
var src = 'dist/' + BUILDS.uncompressed;
return gulp.src(src)
.pipe(filelog('uglify'))
.pipe(expect(EXPECT_OPTS, src))
.pipe(uglify())
.pipe(header(BANNER, BANNER_OPTS))
.pipe(rename(BUILDS.compressed))
.pipe(gulp.dest('dist/'));
});
gulp.task('devel', gulp.series('lint', 'browserify'));
gulp.task('dist', gulp.series('lint', 'browserify', 'uglify'));
gulp.task('default', gulp.series('dist'));