Commit 00ae153a556f4687b480177de65a5c63ebfc9ff9
1 parent
d22e971b73
Exists in
master
and in
1 other branch
fix gulp error en clean y uglify-spec
Showing
1 changed file
with
6 additions
and
3 deletions
Show diff stats
gulpfile.js
| 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 | 15 | ||
| 15 | var paths = { | 16 | var paths = { |
| 16 | srcJS: 'src/js/*.js', | 17 | srcJS: 'src/js/*.js', |
| 17 | srcViews: 'src/views/*.html', | 18 | srcViews: 'src/views/*.html', |
| 18 | specs: 'spec/*.js', | 19 | specs: 'spec/*.js', |
| 19 | tmp: 'tmp', | 20 | tmp: 'tmp', |
| 20 | dist: 'dist/' | 21 | dist: 'dist/' |
| 21 | }; | 22 | }; |
| 22 | 23 | ||
| 23 | gulp.task('templates', ['clean'], function() { | 24 | gulp.task('uglify', gulpSequence('clean', ['templates', 'uglify-spec'], 'uglify-app')); |
| 25 | |||
| 26 | gulp.task('templates', function() { | ||
| 24 | return pump( | 27 | return pump( |
| 25 | [ | 28 | [ |
| 26 | gulp.src(paths.srcViews), | 29 | gulp.src(paths.srcViews), |
| 27 | htmlmin(), | 30 | htmlmin(), |
| 28 | templateCache('views.js', { | 31 | templateCache('views.js', { |
| 29 | module: 'focaCrearHojaRuta', | 32 | module: 'focaCrearHojaRuta', |
| 30 | root: '' | 33 | root: '' |
| 31 | }), | 34 | }), |
| 32 | gulp.dest(paths.tmp) | 35 | gulp.dest(paths.tmp) |
| 33 | ] | 36 | ] |
| 34 | ); | 37 | ); |
| 35 | }); | 38 | }); |
| 36 | 39 | ||
| 37 | gulp.task('uglify', ['templates', 'uglify-spec'], function() { | 40 | gulp.task('uglify-app', function() { |
| 38 | return pump( | 41 | return pump( |
| 39 | [ | 42 | [ |
| 40 | gulp.src([ | 43 | gulp.src([ |
| 41 | paths.srcJS, | 44 | paths.srcJS, |
| 42 | 'tmp/views.js' | 45 | 'tmp/views.js' |
| 43 | ]), | 46 | ]), |
| 44 | concat('foca-crear-hoja-ruta.js'), | 47 | concat('foca-crear-hoja-ruta.js'), |
| 45 | replace('src/views/', ''), | 48 | replace('src/views/', ''), |
| 46 | gulp.dest(paths.tmp), | 49 | gulp.dest(paths.tmp), |
| 47 | rename('foca-crear-hoja-ruta.min.js'), | 50 | rename('foca-crear-hoja-ruta.min.js'), |
| 48 | uglify(), | 51 | uglify(), |
| 49 | gulp.dest(paths.dist) | 52 | gulp.dest(paths.dist) |
| 50 | ] | 53 | ] |
| 51 | ); | 54 | ); |
| 52 | }); | 55 | }); |
| 53 | 56 | ||
| 54 | gulp.task('uglify-spec', function() { | 57 | gulp.task('uglify-spec', function() { |
| 55 | return pump([ | 58 | return pump([ |
| 56 | gulp.src(paths.specs), | 59 | gulp.src(paths.specs), |
| 57 | concat('foca-crear-hoja-ruta.spec.js'), | 60 | concat('foca-crear-hoja-ruta.spec.js'), |
| 58 | replace("src/views/", ''), | 61 | replace("src/views/", ''), |
| 59 | header("describe('Módulo foca-crear-hoja-ruta', function() { \n"), | 62 | header("describe('Módulo foca-crear-hoja-ruta', function() { \n"), |
| 60 | footer("});"), | 63 | footer("});"), |
| 61 | gulp.dest(paths.dist) | 64 | gulp.dest(paths.dist) |
| 62 | ]); | 65 | ]); |
| 63 | }); | 66 | }); |
| 64 | 67 | ||
| 65 | gulp.task('clean', function() { | 68 | gulp.task('clean', function() { |
| 66 | return gulp.src(['tmp', 'dist'], {read: false}) | 69 | return gulp.src(['tmp', 'dist'], {read: false}) |
| 67 | .pipe(clean()); | 70 | .pipe(clean()); |
| 68 | }); | 71 | }); |
| 69 | 72 | ||
| 70 | gulp.task('pre-commit', function() { | 73 | gulp.task('pre-commit', function() { |
| 71 | return pump( | 74 | return pump( |
| 72 | [ | 75 | [ |
| 73 | gulp.src([paths.srcJS, paths.specs]), | 76 | gulp.src([paths.srcJS, paths.specs]), |
| 74 | jshint('.jshintrc'), | 77 | jshint('.jshintrc'), |
| 75 | jshint.reporter('default'), | 78 | jshint.reporter('default'), |
| 76 | jshint.reporter('fail') | 79 | jshint.reporter('fail') |
| 77 | ] | 80 | ] |
| 78 | ); | 81 | ); |
| 79 | 82 | ||
| 80 | gulp.start('uglify'); | 83 | gulp.start('uglify'); |
| 81 | }); | 84 | }); |
| 82 | 85 | ||
| 83 | gulp.task('webserver', function() { | 86 | gulp.task('webserver', function() { |
| 84 | pump [ | 87 | pump [ |
| 85 | connect.server({port: 3300, host: '0.0.0.0'}) | 88 | connect.server({port: 3300, host: '0.0.0.0'}) |
| 86 | ] | 89 | ]; |
| 87 | }); | 90 | }); |
| 88 | 91 | ||
| 89 | gulp.task('clean-post-install', function() { | 92 | gulp.task('clean-post-install', function() { |
| 90 | return gulp.src(['src', 'tmp', '.jshintrc','readme.md', '.gitignore', 'gulpfile.js', | 93 | return gulp.src(['src', 'tmp', '.jshintrc','readme.md', '.gitignore', 'gulpfile.js', |
| 91 | 'index.html', 'test.html', 'spec'], {read: false}) | 94 | 'index.html', 'test.html', 'spec'], {read: false}) |
| 92 | .pipe(clean()); | 95 | .pipe(clean()); |
| 93 | }); | 96 | }); |
| 94 | 97 | ||
| 95 | gulp.task('default', ['webserver']); | 98 | gulp.task('default', ['webserver']); |
| 96 | 99 | ||
| 97 | gulp.task('watch', function() { | 100 | gulp.task('watch', function() { |
| 98 | gulp.watch([paths.srcJS, paths.srcViews], ['uglify']); | 101 | gulp.watch([paths.srcJS, paths.srcViews], ['uglify']); |
| 99 | }); | 102 | }); |
| 100 | 103 |