test.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #!/usr/bin/env node
  2. var cp = require('child_process')
  3. var fs = require('fs')
  4. var path = require('path')
  5. var shouldRunBrowserTests = !process.env.TRAVIS_PULL_REQUEST ||
  6. process.env.TRAVIS_PULL_REQUEST === 'false'
  7. var node = cp.spawn('npm', ['run', 'test-node'], { stdio: 'inherit' })
  8. node.on('close', function (code) {
  9. if (code === 0 && shouldRunBrowserTests) {
  10. runBrowserTests()
  11. } else {
  12. process.exit(code)
  13. }
  14. })
  15. function runBrowserTests () {
  16. var zuulYmlPath = path.join(__dirname, '..', '.zuul.yml')
  17. writeES5ZuulYml()
  18. cp.spawn('npm', ['run', 'test-browser-es5'], { stdio: 'inherit' })
  19. .on('close', function (code) {
  20. if (code !== 0) process.exit(code)
  21. writeES6ZuulYml()
  22. cp.spawn('npm', ['run', 'test-browser-es6'], { stdio: 'inherit' })
  23. .on('close', function (code) {
  24. process.exit(code)
  25. })
  26. })
  27. function writeES5ZuulYml () {
  28. fs.writeFileSync(zuulYmlPath, fs.readFileSync(path.join(__dirname, 'zuul-es5.yml')))
  29. }
  30. function writeES6ZuulYml () {
  31. fs.writeFileSync(zuulYmlPath, fs.readFileSync(path.join(__dirname, 'zuul-es6.yml')))
  32. }
  33. }