-
Notifications
You must be signed in to change notification settings - Fork 6
/
gulpfile.js
80 lines (72 loc) · 2.54 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
var gulp = require('gulp'),
clean = require('gulp-clean'),
jshint = require('gulp-jshint'),
map = require('vinyl-map'),
istanbul = require('istanbul'),
karma = require('gulp-karma'),
coveralls = require('gulp-coveralls'),
header = require('gulp-header'),
rename = require('gulp-rename'),
uglify = require('gulp-uglify'),
pkg = require('./package.json'),
browserify = require('browserify'),
source = require('vinyl-source-stream'),
buffer = require('vinyl-buffer'),
path = require('path'),
template = require('lodash').template;
gulp.task('default', ['clean', 'lint', 'test', 'compile']);
gulp.task('dev', ['compile', 'lint', 'test', 'watch']);
gulp.task('watch', function() {
gulp.watch('lib/**/*.js', ['test', 'lint', 'compile']);
gulp.watch('test/spec/**/*.js', ['test']);
});
gulp.task('clean', function() {
return gulp.src(['dist', 'test/coverage'], { read: false })
.pipe(clean());
});
gulp.task('lint', function() {
return gulp.src(['gulpfile.js', 'lib/**/*.js', 'specs/**/*.js'])
.pipe(jshint('.jshintrc'))
.pipe(jshint.reporter('jshint-stylish'));
});
gulp.task('instrument', function() {
return gulp.src('lib/**/*.js')
.pipe(map(function(code, filename) {
var instrumenter = new istanbul.Instrumenter(),
relativePath = path.relative(__dirname, filename);
return instrumenter.instrumentSync(code.toString(), relativePath);
}))
.pipe(gulp.dest('lib-instrumented'));
});
gulp.task('test', ['clean', 'instrument'], function() {
return gulp.src(['test/spec/*Spec.js'])
.pipe(karma({ configFile: 'karma.conf.js' }));
});
gulp.task('coveralls', ['test'], function() {
return gulp.src(['test/coverage/**/lcov.info'])
.pipe(coveralls());
});
gulp.task('compile', ['clean'], function() {
return browserify('./lib/bespoke-scale.js')
.bundle({ standalone: 'bespoke.plugins.scale' })
.pipe(source('bespoke-scale.js'))
.pipe(buffer())
.pipe(header(template([
'/*!',
' * <%= name %> v<%= version %>',
' *',
' * Copyright <%= new Date().getFullYear() %>, <%= author.name %>',
' * This content is released under the <%= licenses[0].type %> license',
' * <%= licenses[0].url %>',
' */\n\n'
].join('\n'), pkg)))
.pipe(gulp.dest('dist'))
.pipe(rename('bespoke-scale.min.js'))
.pipe(uglify())
.pipe(header(template([
'/*! <%= name %> v<%= version %> ',
'© <%= new Date().getFullYear() %> <%= author.name %>, ',
'<%= licenses[0].type %> License */\n'
].join(''), pkg)))
.pipe(gulp.dest('dist'));
});