Skip to content

Commit

Permalink
feat: successfully split Validator's tasks for #11
Browse files Browse the repository at this point in the history
  • Loading branch information
ffoodd committed Jan 23, 2019
1 parent a83f649 commit 404acf5
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 58 deletions.
60 changes: 2 additions & 58 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ const del = require('del');
const newer = require('gulp-newer');
const data = require('gulp-data');
// Tests
const html = require('html-validator');
const w3css = require('w3c-css');
const doiuse = require('doiuse/stream');
const axe = require('gulp-axe-webdriver');
const louis = require('gulp-louis');
Expand Down Expand Up @@ -238,61 +236,6 @@ function watch() {
exports.watch = watch;
exports.default = gulp.series( sync, watch );

/**
* @section Test
* HTML Validation
*/
function markup(done) {
fs.readFile(options.test.grps, 'utf8', (error, response) => {
if (error) {
throw error;
}

html({data: response, format: 'text'})
.then((data) => {
console.log(data)
})
.catch((error) => {
console.error(error)
})
});

done();
}


/**
* @section Test
* CSS Validation
*/
function style(done) {
fs.readFile(options.test.css, 'utf8', (error, response) => {
if (error) {
throw error;
}

w3css.validate({text: response}, function(error, data) {
if(error) {
console.error(error);
} else {
var errors = data.errors;
for (let message in errors) {
console.log(`${errors[message].message} at line ${errors[message].line}`)
}
}
})
});

done();
}


/**
* @section Test
* Validator meta task
*/
exports.validator = gulp.parallel( markup, style );


/**
* @section Test
Expand All @@ -302,6 +245,7 @@ function a11y(done) {
return axe(options.axe, done);
}

exports.validator = require('./tasks/validator');

/**
* @section Test
Expand Down Expand Up @@ -338,7 +282,7 @@ function compat(done) {
* @section Test
* All
*/
exports.test = gulp.parallel( markup, style, compat, a11y, perf );
exports.test = gulp.parallel( require('./tasks/validator'), compat, a11y, perf );


/**
Expand Down
53 changes: 53 additions & 0 deletions tasks/validator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
const fs = require('fs');
const gulp = require('gulp');
const options = require('./options');
const html = require('html-validator');
const w3css = require('w3c-css');

/**
* HTML Validation
*/
function markup(done) {
fs.readFile(options.test.grps, 'utf8', (error, response) => {
if (error) {
throw error;
}

html({data: response, format: 'text'})
.then((data) => {
console.log(data)
})
.catch((error) => {
console.error(error)
})
});

done();
}


/**
* CSS Validation
*/
function style(done) {
fs.readFile(options.test.css, 'utf8', (error, response) => {
if (error) {
throw error;
}

w3css.validate({text: response}, function(error, data) {
if(error) {
console.error(error);
} else {
var errors = data.errors;
for (let message in errors) {
console.log(`${errors[message].message} at line ${errors[message].line}`)
}
}
})
});

done();
}

module.exports = gulp.parallel( markup, style );

0 comments on commit 404acf5

Please sign in to comment.