Skip to content

Commit 0ad9a8c

Browse files
committed
Include stderr in error message for failed commands
1 parent 005ebdb commit 0ad9a8c

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

source/index.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,17 @@ const exec = (command, arguments_, options) => {
3030
// Use `Observable` support if merged https://github.com/sindresorhus/execa/pull/26
3131
const subProcess = execa(command, arguments_, options);
3232

33-
return merge(subProcess.stdout, subProcess.stderr, subProcess).pipe(filter(Boolean));
33+
return merge(subProcess.stdout, subProcess.stderr, subProcess).pipe(
34+
filter(Boolean),
35+
catchError(error => {
36+
// Include stderr in error message for better diagnostics
37+
if (error.stderr) {
38+
error.message = `${error.shortMessage}\n${error.stderr}`;
39+
}
40+
41+
throw error;
42+
}),
43+
);
3444
};
3545

3646
/**

0 commit comments

Comments
 (0)