vnu-jar.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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/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 = !/64-Bit/.test(stderr)
  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. ].join('|')
  24. const args = [
  25. '-jar',
  26. vnu,
  27. '--asciiquotes',
  28. '--skip-non-html',
  29. // Ignore the language code warnings
  30. '--no-langdetect',
  31. '--Werror',
  32. `--filterpattern "${ignores}"`,
  33. './*.html',
  34. 'docs_html/',
  35. 'pages/'
  36. ]
  37. // For the 32-bit Java we need to pass `-Xss512k`
  38. if (is32bitJava) {
  39. args.splice(0, 0, '-Xss512k')
  40. }
  41. return childProcess.spawn('java', args, {
  42. shell: true,
  43. stdio: 'inherit'
  44. })
  45. .on('exit', process.exit)
  46. })