Repository navigation
Expand file tree
/
Copy pathgulpfile.js
More file actions
90 lines (79 loc) · 2.02 KB
/
Copy pathgulpfile.js
File metadata and controls
90 lines (79 loc) · 2.02 KB
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
var gulp = require('gulp'),
path = require('path'),
jshintReporter = require('jshint-stylish'),
plugins = require('gulp-load-plugins')({
config: path.join(__dirname, 'package.json')
});
var path = {
src: {
files: 'src/**/*.js'
},
test: {
files: 'test/**/*.test.js'
}
}
gulp.task('build', function(done) {
var pkg = require('./package.json');
var header = ['/**',
' * <%= pkg.name %>',
' * <%= pkg.description %>',
' * @version v<%= pkg.version %>',
' * @link <%= pkg.homepage %>',
' * @license <%= pkg.license %>',
' */',
'(function () {',
' var root = this;',
''].join('\n');
var footer = ['',
'var BrV = {',
' ie: IE,',
' cpf: CPF,',
' cnpj: CNPJ',
'};',
'var objectTypes = {',
' \'function\': true,',
' \'object\': true',
'};',
'if (objectTypes[typeof module]) {',
' module.exports = BrV; ',
'} else {',
' root.BrV = BrV;',
'}',
'}.call(this));'].join('\n');
gulp.src(path.src.files)
.pipe(plugins.concat('br-validations.js'))
.pipe(plugins.header(header, {pkg: pkg}))
.pipe(plugins.footer(footer))
.pipe(plugins.concat('br-validations.js'))
.pipe(gulp.dest('./releases'))
.pipe(plugins.uglify())
.pipe(plugins.concat('br-validations.min.js'))
.pipe(gulp.dest('./releases'));
done();
});
gulp.task('jshint', function(done) {
gulp.src(path.src.files)
.pipe(plugins.jshint('.jshintrc'))
.pipe(plugins.jshint.reporter(jshintReporter));
done();
});
gulp.task('runtestdot', function() {
gulp.src(path.test.files, {read: false})
.pipe(plugins.mocha({
reporter: 'dot'
}))
.on('error', console.warn.bind(console));
});
gulp.task('runtest', function() {
gulp.src(path.test.files, {read: false})
.pipe(plugins.mocha({
reporter: 'spec'
}))
.on('error', console.warn.bind(console));
});
gulp.task('default', ['jshint', 'build', 'runtestdot'], function() {
gulp.watch(path.src.files, ['jshint', 'build', 'runtestdot']);
});
gulp.task('test', ['jshint', 'build', 'runtest'], function() {
gulp.watch(path.src.files, ['jshint', 'build', 'runtest']);
});