Skip to content

Commit

Permalink
fix: print error on process failing
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed May 17, 2023
1 parent 7dc3d93 commit 37f690b
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions packages/devtools/src/server-rpc/npm.ts
Expand Up @@ -87,10 +87,14 @@ export function setupNpmRPC({ nuxt }: NuxtDevtoolsServerContext) {
restartable: false,
})

await process.getProcess()

if (process.getProcess().exitCode !== 0)
throw new Error('Failed to install module')
const execa = process.getProcess()
await execa

const code = execa.exitCode
if (code !== 0) {
console.error(execa.stderr)
throw new Error(`Failed to install module, process exited with ${code}`)
}

await fs.writeFile(filepath, generated, 'utf-8')
}
Expand Down

0 comments on commit 37f690b

Please sign in to comment.