vnu-jar.js 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #!/usr/bin/env node
  2. /*!
  3. * Script to run vnu-jar if Java is available.
  4. * Copyright 2017-2019 The Bootstrap Authors
  5. * Copyright 2017-2019 Twitter, Inc.
  6. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  7. */
  8. 'use strict'
  9. const childProcess = require('child_process')
  10. const vnu = require('vnu-jar')
  11. childProcess.exec('java -version', (error, stdout, stderr) => {
  12. if (error) {
  13. console.error('Skipping vnu-jar test; Java is missing.')
  14. return
  15. }
  16. const is32bitJava = !stderr.match(/64-Bit/)
  17. // vnu-jar accepts multiple ignores joined with a `|`.
  18. // Also note that the ignores are 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. // Markup used in Components → Forms → Layout → Form grid → Horizontal form is currently invalid,
  25. // but used this way due to lack of support for flexbox layout on <fieldset> element in most browsers
  26. 'Element “legend” not allowed as child of element “div” in this context.*',
  27. // Content → Reboot uses various date/time inputs as a visual example.
  28. // Documentation does not rely on them being usable.
  29. 'The “date” input type is not supported in all browsers.*',
  30. 'The “time” input type is not supported in all browsers.*',
  31. // IE11 doesn't recognise <main> / give the element an implicit "main" landmark.
  32. // Explicit role="main" is redundant for other modern browsers, but still valid.
  33. 'The “main” role is unnecessary for element “main”.',
  34. // Ignore the wrong lanuage code warnings for now; they happen randomly.
  35. 'This document appears to be written in.*'
  36. ].join('|')
  37. const args = [
  38. '-jar',
  39. vnu,
  40. '--asciiquotes',
  41. '--skip-non-html',
  42. '--Werror',
  43. `--filterpattern "${ignores}"`,
  44. '_gh_pages/',
  45. 'js/tests/'
  46. ]
  47. // For the 32-bit Java we need to pass `-Xss512k`
  48. if (is32bitJava) {
  49. args.splice(0, 0, '-Xss512k')
  50. }
  51. return childProcess.spawn('java', args, {
  52. shell: true,
  53. stdio: 'inherit'
  54. })
  55. .on('exit', process.exit)
  56. })