Skip to content

Commit

Permalink
Merge pull request #1374 from alphagov/ldeb-fix-run-script-sync-and-e…
Browse files Browse the repository at this point in the history
…xpect-success

Fix error message for runScriptSyncAndExpectSuccess
  • Loading branch information
lfdebrux committed Jun 10, 2022
2 parents 61fc0e4 + 96db4e6 commit 4374d36
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions __tests__/spec/update-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const bash = process.platform === 'win32' ? 'C:\\Program Files\\Git\\bin\\bash.e
* Throws an error if the spawn fails, but does not throw an error if the
* return status of the script or function is non-zero.
*/
function runScriptSync (fnName, options) {
function runScriptSync (fnName = undefined, options) {
if (typeof fnName === 'object') {
options = fnName
fnName = undefined
Expand Down Expand Up @@ -90,10 +90,15 @@ function runScriptSync (fnName, options) {
return ret
}

function runScriptSyncAndExpectSuccess (fnName, options) {
function runScriptSyncAndExpectSuccess (fnName = undefined, options) {
if (typeof fnName === 'object') {
options = fnName
fnName = undefined
}

const ret = runScriptSync(fnName, options)
if (ret.status !== 0) {
throw new Error(`update.sh in ${path.join(process.cwd(), options.testDir)} failed with status ${ret.status}:\n${ret.stderr}`)
throw new Error(`update.sh in ${path.resolve(options.testDir)} failed with status ${ret.status}:\n${ret.stderr}`)
}
return ret
}
Expand Down

0 comments on commit 4374d36

Please sign in to comment.