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