vnu-jar.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #!/usr/bin/env node
  2. /*!
  3. * Script to run vnu-jar if Java is available.
  4. * Copyright 2017-2021 The Bootstrap Authors
  5. * Copyright 2017-2021 Twitter, Inc.
  6. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  7. */
  8. 'use strict'
  9. const { execFile, spawn } = require('child_process')
  10. const vnu = require('vnu-jar')
  11. execFile('java', ['-version'], (error, stdout, stderr) => {
  12. if (error) {
  13. console.error('Skipping vnu-jar test; Java is missing.')
  14. return
  15. }
  16. const is32bitJava = !/64-Bit/.test(stderr)
  17. // vnu-jar accepts multiple ignores joined with a `|`.
  18. // Also note that the ignores are string regular expressions.
  19. const ignores = [
  20. // "autocomplete" is included in <button> and checkboxes and radio <input>s due to
  21. // Firefox's non-standard autocomplete behavior - see https://bugzilla.mozilla.org/show_bug.cgi?id=654072
  22. 'Attribute “autocomplete” is only allowed when the input type is.*',
  23. 'Attribute “autocomplete” not allowed on element “button” at this point.'
  24. ].join('|')
  25. const args = [
  26. '-jar',
  27. `"${vnu}"`,
  28. '--asciiquotes',
  29. '--skip-non-html',
  30. '--Werror',
  31. `--filterpattern "${ignores}"`,
  32. '_site/',
  33. 'js/tests/'
  34. ]
  35. // For the 32-bit Java we need to pass `-Xss512k`
  36. if (is32bitJava) {
  37. args.splice(0, 0, '-Xss512k')
  38. }
  39. return spawn('java', args, {
  40. shell: true,
  41. stdio: 'inherit'
  42. })
  43. .on('exit', process.exit)
  44. })