Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Replace htmllint helper with htmllint lib. Still depends on grunt as …

…grunt.utils.spawn is pretty convenient
  • Loading branch information...
commit 82670f843726e7228c910ba915176315d0ed3f02 1 parent 1e443ea
@jzaefferer authored
Showing with 24 additions and 36 deletions.
  1. +17 −0 lib/htmllint.js
  2. +4 −30 tasks/html.js
  3. +3 −6 test/html_test.js
View
17 lib/htmllint.js
@@ -0,0 +1,17 @@
+module.exports = function(grunt, files, done) {
+ var jar = __dirname + '/../vnu.jar';
+ grunt.utils.spawn({
+ cmd: 'java',
+ args: ['-Dnu.validator.client.quiet=yes', '-jar', jar].concat(files)
+ }, function(error, output) {
+ if (error) {
+ done(error);
+ return;
+ }
+ var result = [];
+ if (output.stdout) {
+ result = output.stdout.split('\n');
+ }
+ done(null, result);
+ });
+};
View
34 tasks/html.js
@@ -6,19 +6,15 @@
* Licensed under the MIT license.
*/
-module.exports = function(grunt) {
-
- // Please see the grunt documentation for more information regarding task and
- // helper creation: https://github.com/cowboy/grunt/blob/master/docs/toc.md
+var htmllint = require('../lib/htmllint');
- // ==========================================================================
- // TASKS
- // ==========================================================================
+module.exports = function(grunt) {
grunt.registerMultiTask('htmllint', 'Validate html files', function() {
var done = this.async(),
files = grunt.file.expand(this.file.src);
- grunt.helper('htmllint', files, function(error, result) {
+
+ htmllint(grunt, files, function(error, result) {
if (error) {
grunt.log.error(error);
done(false);
@@ -34,26 +30,4 @@ module.exports = function(grunt) {
});
});
- // ==========================================================================
- // HELPERS
- // ==========================================================================
-
- grunt.registerHelper('htmllint', function(files, done) {
- var jar = __dirname + '/../vnu.jar';
- grunt.utils.spawn({
- cmd: 'java',
- args: ['-Dnu.validator.client.quiet=yes', '-jar', jar].concat(files)
- }, function(error, output) {
- if (error) {
- done(error);
- return;
- }
- var result = [];
- if (output.stdout) {
- result = output.stdout.split('\n');
- }
- done(null, result);
- });
- });
-
};
View
9 test/html_test.js
@@ -1,14 +1,11 @@
-var grunt = require('grunt');
+var grunt = require('grunt'),
+ htmllint = require('../lib/htmllint');
exports['htmllint'] = {
- setUp: function(done) {
- // setup here
- done();
- },
'helper': function(test) {
test.expect(1);
// tests here
- grunt.helper('htmllint', ['test/valid.html', 'test/invalid.html'], function(error, result) {
+ htmllint(grunt, ['test/valid.html', 'test/invalid.html'], function(error, result) {
if (error) {
throw error;
}

0 comments on commit 82670f8

Please sign in to comment.
Something went wrong with that request. Please try again.