From 1b6ee5284928319da3b1834fc7837fc7ed4220ad Mon Sep 17 00:00:00 2001 From: pantsucat Date: Sun, 20 Sep 2015 15:20:21 +1000 Subject: Add jshint grunt task and dependency --- Gruntfile.js | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'Gruntfile.js') diff --git a/Gruntfile.js b/Gruntfile.js index 2cbd42f..64c2f7a 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -97,7 +97,11 @@ module.exports = function (grunt) { dest: 'dist/' }] } + }, + jshint: { + all: ['Gruntfile.js', 'pomf.js'] } + }); grunt.loadNpmTasks('grunt-swig'); @@ -106,6 +110,7 @@ module.exports = function (grunt) { grunt.loadNpmTasks('grunt-contrib-htmlmin'); grunt.loadNpmTasks('grunt-contrib-cssmin'); grunt.loadNpmTasks('grunt-contrib-imagemin'); + grunt.loadNpmTasks('grunt-contrib-jshint'); grunt.loadNpmTasks('grunt-contrib-copy'); grunt.registerTask('default', ['mkdir', 'swig', 'htmlmin', 'cssmin', 'uglify', 'imagemin', 'copy']); -- cgit v1.2.3 From 2c7aab1dde0e1814434cd79bb05b0f0f40f500e9 Mon Sep 17 00:00:00 2001 From: pantsucat Date: Sun, 20 Sep 2015 15:45:44 +1000 Subject: Add jshint to grunt.registerTask --- Gruntfile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Gruntfile.js') diff --git a/Gruntfile.js b/Gruntfile.js index 64c2f7a..d61a120 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -113,5 +113,5 @@ module.exports = function (grunt) { grunt.loadNpmTasks('grunt-contrib-jshint'); grunt.loadNpmTasks('grunt-contrib-copy'); - grunt.registerTask('default', ['mkdir', 'swig', 'htmlmin', 'cssmin', 'uglify', 'imagemin', 'copy']); + grunt.registerTask('default', ['jshint', 'mkdir', 'swig', 'htmlmin', 'cssmin', 'uglify', 'imagemin', 'copy']); }; -- cgit v1.2.3 From fc638db5fa58614f2839def3d1beb4bce6baf60e Mon Sep 17 00:00:00 2001 From: pantsucat Date: Sun, 20 Sep 2015 22:11:57 +1000 Subject: Add all Javascript files to JSHint task --- Gruntfile.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'Gruntfile.js') diff --git a/Gruntfile.js b/Gruntfile.js index d61a120..28e73dd 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -99,7 +99,15 @@ module.exports = function (grunt) { } }, jshint: { - all: ['Gruntfile.js', 'pomf.js'] + options: { + curly: true, + }, + all: [ + 'Gruntfile.js', + 'js/pomf.js', + 'js/cabinet.js', + 'js/cheesesteak.js' + ] } }); -- cgit v1.2.3 From 579ef95912401c4cca67c18b9f9805a19b48f29f Mon Sep 17 00:00:00 2001 From: WubTheCaptain Date: Sun, 20 Sep 2015 12:20:30 +0000 Subject: Add undef: true check to Gruntfile's JSHint task This should also fix the syntax, which fixes a build failure. --- Gruntfile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Gruntfile.js') diff --git a/Gruntfile.js b/Gruntfile.js index 28e73dd..7013c07 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -101,6 +101,7 @@ module.exports = function (grunt) { jshint: { options: { curly: true, + undef: true }, all: [ 'Gruntfile.js', @@ -109,7 +110,6 @@ module.exports = function (grunt) { 'js/cheesesteak.js' ] } - }); grunt.loadNpmTasks('grunt-swig'); -- cgit v1.2.3 From 8d369769c099c706a12b4b1e1393f718593b20be Mon Sep 17 00:00:00 2001 From: WubTheCaptain Date: Sun, 20 Sep 2015 12:22:32 +0000 Subject: Indent Gruntfile from tabs to two spaces This creates consistency with the project's style. --- Gruntfile.js | 242 +++++++++++++++++++++++++++++------------------------------ 1 file changed, 121 insertions(+), 121 deletions(-) (limited to 'Gruntfile.js') diff --git a/Gruntfile.js b/Gruntfile.js index 7013c07..41feacc 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,125 +1,125 @@ module.exports = function (grunt) { - grunt.initConfig({ - pkg: grunt.file.readJSON('package.json'), - swig: { - dist: { - init: { - root: "pages/", - allowErrors: false, - autoescape: true - }, - banners: grunt.file.readJSON('pages/banners.json'), - max_upload_size: 120, - dest: "dist/", - cwd: "pages/", - generateSitemap: false, - generateRobotstxt: false, - src: [ - 'index.swig', - 'faq.swig', - 'tools.swig', - 'other.swig', - 'nojs.swig', - 'ca.swig' - ], - siteUrl: 'https://pantsu.cat/', - production: false, - } - }, - htmlmin: { - dist: { - options: { - removeComments: true, - collapseWhitespace: true, - conservativeCollapse: true, - removeEmptyAttributes: true - }, - files: [{ - expand: true, - cwd: 'dist/', - src: '**/*.html', - dest: 'dist/' - }] - } - }, - uglify: { - options: { - banner: '/*! <%= pkg.name %> (<%= pkg.repository.url %>) @ <%= grunt.template.today("yyyy-mm-dd") %> */\n' + - '// @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT\n', - footer: '\n// @license-end', - screwIE8: true - }, - dist: { - files: { - 'dist/pomf.min.js': [ - 'js/zepto.js', - 'js/cheesesteak.js', - 'js/cabinet.js', - 'js/pomf.js' - ] - } - } - }, - cssmin: { - options: { - banner: '/*! <%= pkg.name %> (<%= pkg.repository.url %>) @ <%= grunt.template.today("yyyy-mm-dd") %> */\n\n' - }, - dist: { - files: { - 'dist/pomf.min.css': [ - 'css/pomf.css' - ] - } - } - }, - mkdir: { - options: { - mode: 0700, - create: ['dist/img'] - } - }, - imagemin: { - dist: { - files: [{ - expand: true, - cwd: 'img/', - src: '**/*.{png,jpg,gif}', - dest: 'dist/img/' - }] - } - }, - copy: { - dist: { - files: [{ - expand: true, - cwd: 'static/', - src: '**', - dest: 'dist/' - }] - } - }, - jshint: { - options: { - curly: true, - undef: true - }, - all: [ - 'Gruntfile.js', - 'js/pomf.js', - 'js/cabinet.js', - 'js/cheesesteak.js' - ] - } - }); + grunt.initConfig({ + pkg: grunt.file.readJSON('package.json'), + swig: { + dist: { + init: { + root: "pages/", + allowErrors: false, + autoescape: true + }, + banners: grunt.file.readJSON('pages/banners.json'), + max_upload_size: 120, + dest: "dist/", + cwd: "pages/", + generateSitemap: false, + generateRobotstxt: false, + src: [ + 'index.swig', + 'faq.swig', + 'tools.swig', + 'other.swig', + 'nojs.swig', + 'ca.swig' + ], + siteUrl: 'https://pantsu.cat/', + production: false, + } + }, + htmlmin: { + dist: { + options: { + removeComments: true, + collapseWhitespace: true, + conservativeCollapse: true, + removeEmptyAttributes: true + }, + files: [{ + expand: true, + cwd: 'dist/', + src: '**/*.html', + dest: 'dist/' + }] + } + }, + uglify: { + options: { + banner: '/*! <%= pkg.name %> (<%= pkg.repository.url %>) @ <%= grunt.template.today("yyyy-mm-dd") %> */\n' + + '// @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT\n', + footer: '\n// @license-end', + screwIE8: true + }, + dist: { + files: { + 'dist/pomf.min.js': [ + 'js/zepto.js', + 'js/cheesesteak.js', + 'js/cabinet.js', + 'js/pomf.js' + ] + } + } + }, + cssmin: { + options: { + banner: '/*! <%= pkg.name %> (<%= pkg.repository.url %>) @ <%= grunt.template.today("yyyy-mm-dd") %> */\n\n' + }, + dist: { + files: { + 'dist/pomf.min.css': [ + 'css/pomf.css' + ] + } + } + }, + mkdir: { + options: { + mode: 0700, + create: ['dist/img'] + } + }, + imagemin: { + dist: { + files: [{ + expand: true, + cwd: 'img/', + src: '**/*.{png,jpg,gif}', + dest: 'dist/img/' + }] + } + }, + copy: { + dist: { + files: [{ + expand: true, + cwd: 'static/', + src: '**', + dest: 'dist/' + }] + } + }, + jshint: { + options: { + curly: true, + undef: true + }, + all: [ + 'Gruntfile.js', + 'js/pomf.js', + 'js/cabinet.js', + 'js/cheesesteak.js' + ] + } + }); - grunt.loadNpmTasks('grunt-swig'); - grunt.loadNpmTasks('grunt-mkdir'); - grunt.loadNpmTasks('grunt-contrib-uglify'); - grunt.loadNpmTasks('grunt-contrib-htmlmin'); - grunt.loadNpmTasks('grunt-contrib-cssmin'); - grunt.loadNpmTasks('grunt-contrib-imagemin'); - grunt.loadNpmTasks('grunt-contrib-jshint'); - grunt.loadNpmTasks('grunt-contrib-copy'); + grunt.loadNpmTasks('grunt-swig'); + grunt.loadNpmTasks('grunt-mkdir'); + grunt.loadNpmTasks('grunt-contrib-uglify'); + grunt.loadNpmTasks('grunt-contrib-htmlmin'); + grunt.loadNpmTasks('grunt-contrib-cssmin'); + grunt.loadNpmTasks('grunt-contrib-imagemin'); + grunt.loadNpmTasks('grunt-contrib-jshint'); + grunt.loadNpmTasks('grunt-contrib-copy'); - grunt.registerTask('default', ['jshint', 'mkdir', 'swig', 'htmlmin', 'cssmin', 'uglify', 'imagemin', 'copy']); + grunt.registerTask('default', ['jshint', 'mkdir', 'swig', 'htmlmin', 'cssmin', 'uglify', 'imagemin', 'copy']); }; -- cgit v1.2.3 From f24e5ee6ad88c40f813102d385ccdc4ee7b44c6d Mon Sep 17 00:00:00 2001 From: WubTheCaptain Date: Sun, 20 Sep 2015 12:31:12 +0000 Subject: Remove Gruntfile from JSHint testing There's no sense to test the Gruntfile at this time, because it will always fail to module.exports which works as intended. --- Gruntfile.js | 1 - 1 file changed, 1 deletion(-) (limited to 'Gruntfile.js') diff --git a/Gruntfile.js b/Gruntfile.js index 41feacc..5a1bd94 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -104,7 +104,6 @@ module.exports = function (grunt) { undef: true }, all: [ - 'Gruntfile.js', 'js/pomf.js', 'js/cabinet.js', 'js/cheesesteak.js' -- cgit v1.2.3 From e88b0a008de53cd344bf67d02392f241edbe16db Mon Sep 17 00:00:00 2001 From: WubTheCaptain Date: Sun, 20 Sep 2015 12:33:03 +0000 Subject: Move JSHint task away from default/dist to test It should not be fatal to fail the build process if there's a syntax error somewhere. Users don't need to care about that too much, only developers should. --- Gruntfile.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Gruntfile.js') diff --git a/Gruntfile.js b/Gruntfile.js index 5a1bd94..c0249cb 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -120,5 +120,6 @@ module.exports = function (grunt) { grunt.loadNpmTasks('grunt-contrib-jshint'); grunt.loadNpmTasks('grunt-contrib-copy'); - grunt.registerTask('default', ['jshint', 'mkdir', 'swig', 'htmlmin', 'cssmin', 'uglify', 'imagemin', 'copy']); + grunt.registerTask('default', ['mkdir', 'swig', 'htmlmin', 'cssmin', 'uglify', 'imagemin', 'copy']); + grunt.registerTask('test', ['jshint']); }; -- cgit v1.2.3