Skip to content

Commit

Permalink
fix: add more verbose output
Browse files Browse the repository at this point in the history
  • Loading branch information
bahmutov committed Mar 29, 2018
1 parent 0dd2937 commit 865561c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,16 @@ const Promise = require('bluebird')
const psTree = require('ps-tree')
const debug = require('debug')('start-server-and-test')

const isDebug = () =>
process.env.DEBUG && process.env.DEBUG.indexOf('start-server-and-test') !== -1

function startAndTest ({ start, url, test }) {
la(is.unemptyString(start), 'missing start script name', start)
la(is.unemptyString(test), 'missing test script name', test)
la(is.unemptyString(url), 'missing url to wait on', url)

debug('starting server')
debug('starting server, verbose mode?', isDebug())

const server = execa('npm', ['run', start], { stdio: 'inherit' })
let serverStopped

Expand All @@ -36,19 +40,21 @@ function startAndTest ({ start, url, test }) {
}

const waited = new Promise((resolve, reject) => {
debug('starting waitOn %s', url)
waitOn(
{
resources: [url],
interval: 1000,
window: 100,
verbose: false
verbose: isDebug()
},
err => {
if (err) {
debug('error waiting for url', url)
debug(err.message)
return reject(err)
}
debug('waitOn finished successfully')
resolve()
}
)
Expand Down

0 comments on commit 865561c

Please sign in to comment.