-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
193 lines (151 loc) · 4.28 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
/*!!
*
* gulpfile.js
* @author: Jan Sanchez
*
*/
var gulp = require('gulp'),
changelog = require('conventional-changelog'),
bump = require('gulp-bump'),
tagVersion = require('gulp-tag-version'),
filter = require('gulp-filter'),
fs = require('fs'),
loadPlugins = require('gulp-load-plugins'),
package = require('./package.json'),
notify = require("node-notifier"),
path = require('./gulp/path'),
options = require('./gulp/options');
var notifier = new notify(),
plugins = loadPlugins();
plugins.runSequence = require('run-sequence');
var coffeeTasks = ['js'];
/*!!
*
* Tareas para changelog, tag
*
* tarea principal: gulp
*/
gulp.task('log', function () {
return changelog({
repository: package.repository.url,
version: package.version
}, function(err, log) {
fs.writeFileSync('CHANGELOG.md', log, 'utf8');
});
});
gulp.task('bump', function(){
return gulp.src(['./package.json'])
.pipe(bump())
.pipe(gulp.dest('./'))
.pipe(filter('package.json'))
.pipe(tagVersion());
});
gulp.task('version', function (cb) {
plugins.runSequence(['log', 'bump'], cb);
});
/*!!
*
* Tareas individuales para limpiar los archivos generados
*
* tarea principal: gulp clean
*/
gulp.task('clean:js:package', function () {
return gulp.src(path.clean.js.package, options.clean.general.src)
.pipe(plugins.rimraf(options.clean.general.plugin));
});
gulp.task('clean:js:test', function () {
return gulp.src(path.clean.js.test, options.clean.general.src)
.pipe(plugins.rimraf(options.clean.general.plugin));
});
gulp.task('clean:js', function (cb) {
return plugins.runSequence(['clean:js:package', 'clean:js:test'], cb);
});
gulp.task('clean', function (cb) {
plugins.runSequence(['clean:js'], cb);
});
/*!!
*
* Tareas para copiar archivos
*
* tarea principal: gulp copy
*/
gulp.task('copy:js:test', function () {
gulp.src(path.copy.js.test.src, {
base: path.copy.js.test.base
})
.pipe(gulp.dest(path.copy.js.test.dest));
});
/*!!
*
* Tareas para generar, concatenar, lintear Javascript
*
* tarea principal: gulp js
*/
gulp.task('coffee', function() {
return gulp.src(path.coffee.default.src)
.pipe(plugins.coffee(options.coffee.general).on('error', function(err){
console.log('');
console.log(err.name + " in " + err.plugin);
console.log('Message: ' + err.message);
console.log('Stack: ' + err.stack);
var isLinux = /^linux/.test(process.platform);
if (isLinux){
notifier.notify({
title: 'Plugin: ' + err.plugin,
message: err.name + ' in ' + err.plugin,
contentImage: __dirname + "/gulp/img/logo.png",
appIcon: __dirname + "/gulp/img/logo.png",
open: "file://" + __dirname + "/gulp/img/logo.png"
}, function(error, response) {
console.log(response);
});
}
}))
.pipe(gulp.dest(path.coffee.default.dest));
});
gulp.task('lint', function() {
return gulp.src(path.javascript.lint)
.pipe(plugins.jshint(options.js.lint.jshintrc))
.pipe(plugins.jshint.reporter(options.js.lint.reporterStyle))
.pipe(plugins.jshint.reporter(options.js.lint.reporter));
});
gulp.task('complexity', function(){
return gulp.src(path.javascript.complexity)
.pipe(plugins.complexity({breakOnErrors: false}));
});
gulp.task('js', function(cb) {
plugins.runSequence('clean:js', 'coffee', 'copy:js:test', 'clean:js:test', 'lint', 'complexity', cb);
});
gulp.task('watch', function () {
gulp.watch(path.watch.coffee, coffeeTasks);
});
/*!!
*
* Tareas por default
*
* tarea principal: gulp
*/
gulp.task('default', [], function (cb) {
plugins.runSequence('js', cb);
});
gulp.task('test', function () {
return gulp.src(path.mocha.js.test, {read: false})
.pipe(plugins.mocha({
reporter: 'spec',
recursive: true,
globals: {
should: require('should'),
assert: require('assert')
}
}
));
});
/*
* Task for test my package
*/
var gulpCssVersioner = require('./dist/package/index.js')
gulp.task('versioner', function () {
return gulp.src(['test/css/*.css'])
.pipe(gulpCssVersioner({debug: true}))
.pipe(gulp.dest('test/css/versioned/'))
});