-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
120 lines (102 loc) · 2.91 KB
/
gulpfile.js
File metadata and controls
120 lines (102 loc) · 2.91 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
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
var gulp = require('gulp');
var plug = require('gulp-load-plugins')();
var path = require('path');
var paths = {
js: [
'./scripts/app.js',
'./scripts/tools.js',
'./scripts/wikieditor.js',
'./scripts/wikiTpl.js'
],
angular: [
'./bower_components/angular/angular.min.js',
'./bower_components/angular-route/angular-route.min.js',
'./bower_components/angular-sanitize/angular-sanitize.min.js'
],
styles: [
'./css/styles.css',
'./bower_components/bootstrap/dist/css/bootstrap.min.css'
],
build: './build'
};
/**
* Lista las tareas gulp habilitadas
*/
gulp.task('help', plug.taskListing);
/**
* Minifica y empaqueta la aplicacion JavaScript
* @return {Stream}
*/
gulp.task('jsmin', function() {
console.log('Empaquetando, minificando, y copiando los JS');
return gulp
.src(paths.js)
.pipe(plug.concat('lazyWiki.min.js'))
.pipe(plug.uglify({}))
.pipe(gulp.dest(paths.build+'/js'));
});
gulp.task('js', function() {
console.log('Empaquetando, minificando, y copiando los JS');
return gulp
.src(paths.js)
.pipe(plug.concat('lazyWiki.js'))
.pipe(gulp.dest(paths.build+'/js/'));
});
gulp.task('angular', function(){
console.log('Copiando librerias angular');
return gulp
.src(paths.angular)
.pipe(gulp.dest(paths.build+'/js/'));
});
gulp.task('indexProd', function(){
console.log('Genera la pagina de produccion');
return gulp
.src('./index.html')
.pipe(plug.useref())
.pipe(gulp.dest(paths.build));
});
gulp.task('eslint', function() {
console.log('Realizando verificaciones de calidad de codigo');
return gulp
.src(paths.js)
.pipe(plug.eslint())
.pipe(plug.eslint.format())
.pipe(plug.eslint.failAfterError());
});
gulp.task('copyAssets', function(){
console.log('Copiando assets');
return gulp
.src('assets/**')
.pipe(gulp.dest(paths.build+'/assets'));
});
gulp.task('copyStyles', function(){
console.log('Copiando estilos');
return gulp
.src(paths.styles)
.pipe(gulp.dest(paths.build+'/css'));
});
gulp.task('build', ['jsmin', 'copyAssets', 'angular', 'indexProd', 'copyStyles']);
/**
* Ejecuta las pruebas de la aplicacion
*
* @todo Agregar las pruebas respectivas con karma y qunit o jasmine
* @return {Stream}
*/
gulp.task('test', ['build'], function(done) {
startTests(true, done);
});
/**
* Start the tests using karma.
* @param {boolean} singleRun - True means run once and end (CI), or keep running (dev)
* @param {Function} done - Callback to fire when karma is done
* @return {undefined}
*/
function startTests(singleRun, done) {
karma.start({
configFile: path.join(__dirname, '/karma.conf.js'),
singleRun: !!singleRun
}, karmaCompleted);
function karmaCompleted() {
done();
}
}