Skip to content

Commit

Permalink
Bubble up errors from webpack run
Browse files Browse the repository at this point in the history
  • Loading branch information
Vladimir Pouzanov committed Dec 31, 2017
1 parent afd09d1 commit 9477ff8
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions packages/gatsby/src/commands/build-javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,20 @@ module.exports = async program => {
`build-javascript`
)

return new Promise(resolve => {
webpack(compilerConfig.resolve()).run(() => resolve())
return new Promise((resolve, reject) => {
webpack(compilerConfig.resolve()).run((err, stats) => {
if (err) {
reject(err)
return
}

const jsonStats = stats.toJson()
if (jsonStats.errors && jsonStats.errors.length > 0) {
reject(jsonStats.errors[0])
return
}

resolve()
})
})
}

0 comments on commit 9477ff8

Please sign in to comment.