mozilla/html5-lint

Integrate HTML5 Validator with GitLab CI/CD using NodeJS

Closed this issue · 1 comments

I wish to integrate this package into my GitLab CI/CD. However, when displaying with GitLab CI/CD, it has a result of success.

Screenshot at Sep 25 10-38-59

Do you know the best way to output error to command and stop pipeline display as success?

Thanks.

Here is my sources:

Test HTML5 Validation:
 stage: test
 script:
 - npm run test:html5

In package.json

"scripts": {
  "test:html5": "node html5-lint.js"
}

In html5-lint.js

const fs = require('fs')
const html5Lint = require('html5-lint')

console.log('Start HTML5 lint checking')

fs.readFile('index.html', 'utf8', function (err, html) {
  if (err) { throw err }

  console.log('Running...')

  html5Lint(html, (err, results) => {
    results.messages.forEach(function (msg) {
      var type = msg.type
      var message = msg.message

      console.log('HTML5 Lint [%s]: %s', type, message)
    })
  })
})

I resolved it by adding process.exit(0) or process.exit(1).