Skip to content

Commit 8e6622f

Browse files
author
Guillaume Chau
committed
fix(task): shell mode (fix cd) + more robust error handing
1 parent 0ee1983 commit 8e6622f

File tree

1 file changed

+33
-2
lines changed
  • packages/@vue/cli-ui/apollo-server/connectors

1 file changed

+33
-2
lines changed

packages/@vue/cli-ui/apollo-server/connectors/tasks.js

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,8 @@ async function run (id, context) {
298298

299299
const child = execa(command, args, {
300300
cwd: cwd.get(),
301-
stdio: ['inherit', 'pipe', 'pipe']
301+
stdio: ['inherit', 'pipe', 'pipe'],
302+
shell: true
302303
})
303304

304305
if (typeof nodeEnv !== 'undefined') {
@@ -409,6 +410,28 @@ async function run (id, context) {
409410

410411
child.on('exit', onExit)
411412

413+
child.on('error', error => {
414+
updateOne({
415+
id: task.id,
416+
status: 'error'
417+
}, context)
418+
logs.add({
419+
message: `Error while running task ${task.id} with message'${error.message}'`,
420+
type: 'error'
421+
}, context)
422+
notify({
423+
title: `Task error`,
424+
message: `Error while running task ${task.id} with message'${error.message}'`,
425+
icon: 'error'
426+
})
427+
addLog({
428+
taskId: task.id,
429+
type: 'stdout',
430+
text: chalk.red(`Error while running task ${task.id} with message '${error.message}'`)
431+
}, context)
432+
console.error(error)
433+
})
434+
412435
// Plugin API
413436
if (task.onRun) {
414437
await task.onRun({
@@ -436,7 +459,15 @@ function stop (id, context) {
436459
const task = findOne(id, context)
437460
if (task && task.status === 'running' && task.child) {
438461
task._terminating = true
439-
terminate(task.child.pid)
462+
try {
463+
terminate(task.child.pid)
464+
} catch (e) {
465+
console.error(e)
466+
updateOne({
467+
id: task.id,
468+
status: 'terminated'
469+
}, context)
470+
}
440471
}
441472
return task
442473
}

0 commit comments

Comments
 (0)