forked from alexmingoia/virtual-dom-component
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gulpfile.js
83 lines (68 loc) · 2.12 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
/*!
* virtual-dom-component
* https://github.com/alexmingoia/virtual-dom-component
*
* Copyright (c) 2014 Alex Mingoia <[email protected]>
* Licensed under the BSD license.
*/
'use strict';
var Browserify = require('browserify')
, clean = require('gulp-clean')
, gulp = require('gulp')
, instrument = require('gulp-instrument')
, jshint = require('gulp-jshint')
, mochaPhantomJS = require('gulp-mocha-phantomjs')
, source = require('vinyl-source-stream')
, stylish = require('jshint-stylish')
, spawn = require('child_process').spawn;
gulp.task('coverage', ['instrument'], function() {
process.env.JSCOV=1;
return spawn('node_modules/gulp-mocha-phantomjs/node_modules/mocha-phantomjs/node_modules/mocha/bin/mocha', [
'test', '--reporter', 'html-cov'
]).stdout
.pipe(source('coverage.html'))
.pipe(gulp.dest('./'));
});
gulp.task('instrument', function() {
return gulp.src('lib/**.js')
.pipe(instrument())
.pipe(gulp.dest('lib-cov'));
});
gulp.task('wrap-umd', function() {
var bundler = new Browserify({
standalone: 'VirtualComponent'
});
bundler.add('./lib/virtual-dom-component.js');
bundler.exclude('../lib-cov/virtual-dom-component');
return bundler.bundle()
.pipe(source('virtual-dom-component.js'))
.pipe(gulp.dest('dist'));
});
gulp.task('browserify-tests', function() {
var bundler = new Browserify();
bundler.add('./test/virtual-dom-component.js');
bundler.exclude('../lib-cov/virtual-dom-component');
return bundler.bundle()
.pipe(source('tests.js'))
.pipe(gulp.dest('dist'));
});
gulp.task('mocha-phantomjs', ['browserify-tests'], function() {
return gulp.src('test/virtual-dom-component.html')
.pipe(mochaPhantomJS({
mocha: {
timeout: 6000,
ignoreLeaks: false,
ui: 'bdd',
reporter: 'spec'
}
}));
});
gulp.task('test', ['mocha-phantomjs'], function () {
return gulp.src('dist/tests.js').pipe(clean());
});
gulp.task('jshint', function () {
return gulp.src(['lib/**/*.js', 'test/**/*.js'])
.pipe(jshint())
.pipe(jshint.reporter(stylish));
});
gulp.task('default', ['jshint', 'test']);