-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: successfully split Validator's tasks for #11
- Loading branch information
Showing
2 changed files
with
55 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ); |