From 0fa3808740a307440d8308e232ae8f80bbbedbc4 Mon Sep 17 00:00:00 2001 From: Nicolas Guarnieri Date: Mon, 8 Oct 2018 22:51:37 +0000 Subject: [PATCH] Update package.json, gulpfile.js, .jshintrc files --- .jshintrc | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ gulpfile.js | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ package.json | 2 +- 3 files changed, 134 insertions(+), 1 deletion(-) create mode 100644 .jshintrc create mode 100644 gulpfile.js diff --git a/.jshintrc b/.jshintrc new file mode 100644 index 0000000..d8cbb07 --- /dev/null +++ b/.jshintrc @@ -0,0 +1,64 @@ +{ + /* + * ENVIRONMENTS + * ================= + */ + + // Define globals exposed by modern browsers. + "browser": true, + + // Define globals exposed by jQuery. + "jquery": true, + + // Define globals exposed by Node.js. + "node": true, + + // Allow ES6. + "esversion": 6, + + /* + * ENFORCING OPTIONS + * ================= + */ + + // Force all variable names to use either camelCase style or UPPER_CASE + // with underscores. + "camelcase": true, + + // Prohibit use of == and != in favor of === and !==. + "eqeqeq": true, + + // Enforce tab width of 2 spaces. + "indent": 4, + + // Prohibit use of a variable before it is defined. + "latedef": false, + + // Enforce line length to 100 characters + "maxlen": 100, + + // Require capitalized names for constructor functions. + "newcap": true, + + // Enforce use of single quotation marks for strings. + "quotmark": "single", + + // Enforce placing 'use strict' at the top function scope + "strict": false, + + // Prohibit use of explicitly undeclared variables. + "undef": true, + + // Warn when variables are defined but never used. + "unused": true, + + // Para que funcione en angular + "predef": ["angular", "alert", "spyOn", "expect", "it", "inject", "beforeEach", "describe"], + /* + * RELAXING OPTIONS + * ================= + */ + + // Suppress warnings about == null comparisons. + "eqnull": true +} diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 0000000..654b94b --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,69 @@ +const templateCache = require('gulp-angular-templatecache'); +const concat = require('gulp-concat'); +const htmlmin = require('gulp-htmlmin'); +const rename = require('gulp-rename'); +const uglify = require('gulp-uglify'); +const gulp = require('gulp'); +const pump = require('pump'); +const jshint = require('gulp-jshint'); +const replace = require('gulp-replace'); +const connect = require('gulp-connect'); + +var paths = { + srcJS: 'src/js/*.js', + srcViews: 'src/views/*.html', + tmp: 'tmp', + dist: 'dist/' +}; + +gulp.task('templates', function() { + return pump( + [ + gulp.src(paths.srcViews), + replace('views/', ''), + htmlmin(), + templateCache('views.js', { + module: 'focaBusquedaProductos', + root: '' + }), + gulp.dest(paths.tmp) + ] + ); +}); + +gulp.task('uglify', ['templates'], function() { + return pump( + [ + gulp.src([ + paths.srcJS, + 'tmp/views.js' + ]), + concat('foca-busqueda-productos.js'), + gulp.dest(paths.tmp), + rename('foca-busqueda-productos.min.js'), + uglify(), + gulp.dest(paths.dist) + ] + ); +}); + +gulp.task('pre-commit', function() { + return pump( + [ + gulp.src(paths.srcJS), + jshint('.jshintrc'), + jshint.reporter('default'), + jshint.reporter('fail') + ] + ); + + gulp.start('uglify'); +}); + +gulp.task('webserver', function() { + pump [ + connect.server({port: 3000}) + ] +}); + +gulp.task('default', ['webserver']); \ No newline at end of file diff --git a/package.json b/package.json index 616f233..9b3be45 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1", - "compile": "gulp uglify && gulp html", + "compile": "gulp uglify", "postinstall": "npm run compile && rm -R src && rm index.html && rm .jshintrc && rm gulpfile.js" }, "repository": { -- 1.9.1