Skip to content

Commit

Permalink
Merge pull request #97 from harvard-lil/cli-exit-1-on-error
Browse files Browse the repository at this point in the history
CLI should return exit code != 0 on blocking error
  • Loading branch information
matteocargnelutti authored Mar 29, 2024
2 parents 2bac713 + fcb63a2 commit 7eeab02
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,12 @@ program.command('create')
// `--file` is mandatory
if (!values?.file) {
console.error('Error: --file not provided.')
return
process.exit(1)
}

if (values?.cdxj && !values?.pages) {
console.error('Error: --cdxj option must be used in combination with --pages.')
return
process.exit(1)
}

// Pass options to WACZ
Expand All @@ -120,7 +120,7 @@ program.command('create')
})
} catch (err) {
log.error(`${err}`) // Show simplified report
return
process.exit(1)
}

// Ingest user-provided CDX files, if any.
Expand Down Expand Up @@ -149,6 +149,7 @@ program.command('create')
} catch (err) {
log.trace(err)
log.error('An error occurred while processing user-provided CDXJ indices.')
process.exit(1)
}
}

Expand All @@ -157,8 +158,9 @@ program.command('create')
await archive.process()
log.info(`WACZ file ready: ${values.output}`)
} catch (err) {
log.error(err)
log.trace(err)
log.error('WACZ could not be processed.')
process.exit(1)
}
})

Expand Down

0 comments on commit 7eeab02

Please sign in to comment.