Commit eff4abcb619399814a3f776601b0ce0494585666

Authored by Eric
1 parent 95481f1164
Exists in master and in 1 other branch develop

correct sequence gulp

Showing 1 changed file with 5 additions and 4 deletions   Show diff stats
1 const templateCache = require('gulp-angular-templatecache'); 1 const templateCache = require('gulp-angular-templatecache');
2 const clean = require('gulp-clean'); 2 const clean = require('gulp-clean');
3 const concat = require('gulp-concat'); 3 const concat = require('gulp-concat');
4 const htmlmin = require('gulp-htmlmin'); 4 const htmlmin = require('gulp-htmlmin');
5 const rename = require('gulp-rename'); 5 const rename = require('gulp-rename');
6 const uglify = require('gulp-uglify'); 6 const uglify = require('gulp-uglify');
7 const gulp = require('gulp'); 7 const gulp = require('gulp');
8 const pump = require('pump'); 8 const pump = require('pump');
9 const jshint = require('gulp-jshint'); 9 const jshint = require('gulp-jshint');
10 const replace = require('gulp-replace'); 10 const replace = require('gulp-replace');
11 const connect = require('gulp-connect'); 11 const connect = require('gulp-connect');
12 const header = require('gulp-header'); 12 const header = require('gulp-header');
13 const footer = require('gulp-footer'); 13 const footer = require('gulp-footer');
14 const gulpSequence = require('gulp-sequence'); 14 const gulpSequence = require('gulp-sequence');
15 15
16 var paths = { 16 var paths = {
17 srcJS: 'src/js/*.js', 17 srcJS: 'src/js/*.js',
18 srcViews: 'src/views/*.html', 18 srcViews: 'src/views/*.html',
19 specs: 'spec/*.js', 19 specs: 'spec/*.js',
20 tmp: 'tmp', 20 tmp: 'tmp',
21 dist: 'dist/' 21 dist: 'dist/'
22 }; 22 };
23 23
24 gulp.task('uglify', gulpSequence('clean', ['templates', 'uglify-spec'], 'uglify-app')); 24 gulp.task('uglify', function(callback) {
25 gulpSequence('clean', ['templates', 'uglify-spec'], 'uglify-app')(callback);
26 });
25 27
26 gulp.task('templates', function() { 28 gulp.task('templates', function() {
27 return pump( 29 return pump(
28 [ 30 [
29 gulp.src(paths.srcViews), 31 gulp.src(paths.srcViews),
30 htmlmin(), 32 htmlmin(),
31 templateCache('views.js', { 33 templateCache('views.js', {
32 module: 'focaCrearRemito', 34 module: 'focaCrearRemito',
33 root: '' 35 root: ''
34 }), 36 }),
35 gulp.dest(paths.tmp) 37 gulp.dest(paths.tmp)
36 ] 38 ]
37 ); 39 );
38 }); 40 });
39 41
40 gulp.task('uglify-app', function() { 42 gulp.task('uglify-app', function() {
41 return pump( 43 return pump(
42 [ 44 [
43 gulp.src([ 45 gulp.src([
44 paths.srcJS, 46 paths.srcJS,
45 'tmp/views.js' 47 'tmp/views.js'
46 ]), 48 ]),
47 concat('foca-crear-remito.js'), 49 concat('foca-crear-remito.js'),
48 replace('src/views/', ''), 50 replace('src/views/', ''),
49 gulp.dest(paths.tmp), 51 gulp.dest(paths.tmp),
50 rename('foca-crear-remito.min.js'), 52 rename('foca-crear-remito.min.js'),
51 uglify(), 53 uglify(),
52 gulp.dest(paths.dist) 54 gulp.dest(paths.dist)
53 ] 55 ]
54 ); 56 );
55 }); 57 });
56 58
57 gulp.task('uglify-spec', function() { 59 gulp.task('uglify-spec', function() {
58 return pump( 60 return pump(
59 [ 61 [
60 gulp.src(paths.specs), 62 gulp.src(paths.specs),
61 concat('foca-crear-remito.spec.js'), 63 concat('foca-crear-remito.spec.js'),
62 replace('src/views/', ''), 64 replace('src/views/', ''),
63 header("describe('Módulo foca-crear-remito', function() { \n"), 65 header("describe('Módulo foca-crear-remito', function() { \n"),
64 footer("});"), 66 footer("});"),
65 gulp.dest(paths.dist) 67 gulp.dest(paths.dist)
66 ] 68 ]
67 ); 69 );
68 }); 70 });
69 71
70 gulp.task('clean', function() { 72 gulp.task('clean', function() {
71 return gulp.src(['tmp', 'dist'], {read: false}) 73 return gulp.src(['tmp', 'dist'], {read: false}).pipe(clean());
72 .pipe(clean());
73 }); 74 });
74 75
75 gulp.task('pre-commit', function() { 76 gulp.task('pre-commit', function() {
76 return pump( 77 return pump(
77 [ 78 [
78 gulp.src([paths.srcJS, paths.specs]), 79 gulp.src([paths.srcJS, paths.specs]),
79 jshint('.jshintrc'), 80 jshint('.jshintrc'),
80 jshint.reporter('default'), 81 jshint.reporter('default'),
81 jshint.reporter('fail') 82 jshint.reporter('fail')
82 ] 83 ]
83 ); 84 );
84 85
85 gulp.start('uglify'); 86 gulp.start('uglify');
86 }); 87 });
87 88
88 gulp.task('webserver', function() { 89 gulp.task('webserver', function() {
89 pump [ 90 pump [
90 connect.server({port: 3300, host: '0.0.0.0'}) 91 connect.server({port: 3300, host: '0.0.0.0'})
91 ] 92 ]
92 }); 93 });
93 94
94 gulp.task('clean-post-install', function() { 95 gulp.task('clean-post-install', function() {
95 return gulp.src(['src', 'tmp', '.jshintrc','readme.md', '.gitignore', 'gulpfile.js', 96 return gulp.src(['src', 'tmp', '.jshintrc','readme.md', '.gitignore', 'gulpfile.js',
96 'index.html'], {read: false}) 97 'index.html'], {read: false})
97 .pipe(clean()); 98 .pipe(clean());
98 }); 99 });
99 100
100 gulp.task('default', ['webserver']); 101 gulp.task('default', ['webserver']);
101 102
102 gulp.task('watch', function() { 103 gulp.task('watch', function() {
103 gulp.watch([paths.srcJS, paths.srcViews], ['uglify']); 104 gulp.watch([paths.srcJS, paths.srcViews], ['uglify']);
104 }); 105 });
105 106
106 gulp.task('copy', ['uglify'], function() { 107 gulp.task('copy', ['uglify'], function() {
107 return gulp.src('dist/*.js') 108 return gulp.src('dist/*.js')
108 .pipe(gulp.dest('../../wrapper-demo/node_modules/foca-crear-remito/dist/')); 109 .pipe(gulp.dest('../../wrapper-demo/node_modules/foca-crear-remito/dist/'));
109 }); 110 });
110 111
111 gulp.task('watchAndCopy', function() { 112 gulp.task('watchAndCopy', function() {
112 return gulp.watch([paths.srcJS, paths.srcViews], ['copy']); 113 return gulp.watch([paths.srcJS, paths.srcViews], ['copy']);
113 }); 114 });