@@ -4,9 +4,9 @@ const execa = require('execa')
4
4
const pReduce = require ( 'p-reduce' )
5
5
6
6
const { setEnvChanges } = require ( '../env/changes.js' )
7
- const { cancelBuild } = require ( '../error/cancel' )
8
7
const { addErrorInfo, getErrorInfo } = require ( '../error/info' )
9
8
const { reportBuildError } = require ( '../error/monitor/report' )
9
+ const { serializeErrorStatus } = require ( '../error/parse/serialize_status' )
10
10
const { logCommand, logBuildCommandStart, logCommandSuccess, logPluginError } = require ( '../log/main' )
11
11
const { pipeOutput, unpipeOutput } = require ( '../log/stream' )
12
12
const { startTimer, endTimer } = require ( '../log/timer' )
@@ -58,7 +58,7 @@ const isSuccessCommand = function({ event }) {
58
58
// list of `failedPlugins` (that ran `utils.build.failPlugin()`).
59
59
// If an error arises, runs `onError` events.
60
60
// Runs `onEnd` events at the end, whether an error was thrown or not.
61
- const runCommands = async function ( { commands, configPath, buildDir, nodePath, childEnv, errorMonitor, api } ) {
61
+ const runCommands = async function ( { commands, configPath, buildDir, nodePath, childEnv, errorMonitor } ) {
62
62
const { index : commandsCount , error : errorA , statuses : statusesB } = await pReduce (
63
63
commands ,
64
64
async (
@@ -81,7 +81,6 @@ const runCommands = async function({ commands, configPath, buildDir, nodePath, c
81
81
envChanges,
82
82
statuses,
83
83
errorMonitor,
84
- api,
85
84
error,
86
85
failedPlugins,
87
86
} ,
@@ -116,7 +115,6 @@ const runCommand = async function({
116
115
envChanges,
117
116
statuses,
118
117
errorMonitor,
119
- api,
120
118
error,
121
119
failedPlugins,
122
120
} ) {
@@ -147,7 +145,7 @@ const runCommand = async function({
147
145
const newValues =
148
146
newError === undefined
149
147
? handleCommandSuccess ( { event, package, newEnvChanges, newStatus, methodTimer } )
150
- : await handleCommandError ( { newError, errorMonitor, api } )
148
+ : await handleCommandError ( { newError, errorMonitor } )
151
149
return { ...newValues , newIndex : index + 1 }
152
150
}
153
151
@@ -257,20 +255,21 @@ const handleCommandSuccess = function({ event, package, newEnvChanges, newStatus
257
255
// handlers of the same type have been triggered before propagating
258
256
// - if `utils.build.failPlugin()` was used, print an error and skip next event
259
257
// handlers of that plugin. But do not stop build.
260
- const handleCommandError = async function ( { newError, errorMonitor, api } ) {
258
+ const handleCommandError = async function ( { newError, errorMonitor } ) {
261
259
const { type, location : { package } = { } } = getErrorInfo ( newError )
260
+ const newStatus = serializeErrorStatus ( newError )
262
261
263
262
if ( type === 'failPlugin' ) {
264
- logPluginError ( newError )
265
- await reportBuildError ( newError , errorMonitor )
266
- return { failedPlugin : [ package ] }
263
+ return handleFailPlugin ( { newStatus, package, newError, errorMonitor } )
267
264
}
268
265
269
- if ( type === 'cancelBuild' ) {
270
- await cancelBuild ( api )
271
- }
266
+ return { newError, newStatus }
267
+ }
272
268
273
- return { newError }
269
+ const handleFailPlugin = async function ( { newStatus, package, newError, errorMonitor } ) {
270
+ logPluginError ( newError )
271
+ await reportBuildError ( newError , errorMonitor )
272
+ return { failedPlugin : [ package ] , newStatus }
274
273
}
275
274
276
275
module . exports = { getCommands, isSuccessCommand, runCommands }
0 commit comments