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