diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | bin/test.js | 34 | ||||
-rw-r--r-- | package.json | 3 |
3 files changed, 26 insertions, 12 deletions
@@ -1,2 +1,3 @@ node_modules webtorrent.debug.js +.zuulrc diff --git a/bin/test.js b/bin/test.js index b30a701..1de9eac 100644 --- a/bin/test.js +++ b/bin/test.js @@ -1,20 +1,30 @@ #!/usr/bin/env node var spawn = require('cross-spawn-async') +var findNearestFile = require('find-nearest-file') +var path = require('path') +var userHome = require('user-home') +var pathExists = require('path-exists') -var runSauceLabs = process.env.SAUCE_USERNAME && process.env.SAUCE_ACCESS_KEY +// .zuulrc logic from https://github.com/defunctzombie/zuul/blob/a0de46a5906c84b19f655c487f7c8debe938984d/bin/zuul#L384 +var zuulrcPath = findNearestFile('.zuulrc') || path.join(userHome, '.zuulrc') +var hasSauceLabEnvVars = process.env.SAUCE_USERNAME && process.env.SAUCE_ACCESS_KEY +var runSauceLabs = hasSauceLabEnvVars || pathExists.sync(zuulrcPath) -npmRun('test-node', function (code) { - if (code === 0) { - var scriptName = runSauceLabs ? 'test-browser' : 'test-browser-headless' - npmRun(scriptName, function (code) { - process.exit(code) - }) - } else { - process.exit(code) - } +npmRun('test-node', function () { + npmRun('test-browser-headless', function () { + if (runSauceLabs) { + npmRun('test-browser') + } + }) }) -function npmRun (scriptName, onClose) { - spawn('npm', ['run', scriptName], { stdio: 'inherit' }).on('close', onClose) +function npmRun (scriptName, onSuccess) { + spawn('npm', ['run', scriptName], { stdio: 'inherit' }).on('close', function (code) { + if (code === 0 && onSuccess) { + onSuccess(code) + } else { + process.exit(code) + } + }) } diff --git a/package.json b/package.json index dbf44b1..17ffa8b 100644 --- a/package.json +++ b/package.json @@ -83,12 +83,15 @@ "cross-spawn-async": "^2.0.0", "electron-prebuilt": "^0.36.7", "finalhandler": "^0.4.0", + "find-nearest-file": "^1.0.0", + "path-exists": "^2.1.0", "run-series": "^1.0.2", "serve-static": "^1.9.3", "simple-get": "^2.0.0", "standard": "^6.0.1", "tape": "^4.0.0", "uglify-js": "^2.4.15", + "user-home": "^2.0.0", "zuul": "^3.0.0" }, "homepage": "https://webtorrent.io", |