Skip to content

Commit 52e47de

Browse files
committed
update error from execa in jest-changed-files
1 parent 7bdf929 commit 52e47de

File tree

3 files changed

+25
-9
lines changed

3 files changed

+25
-9
lines changed

e2e/runJest.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import * as path from 'path';
1010
import * as fs from 'fs';
1111
import {Writable} from 'stream';
12-
import execa, {ExecaChildProcess, ExecaReturnValue} from 'execa';
12+
import execa, {ExecaChildProcess, ExecaReturnValue, ExecaSyncReturnValue} from 'execa';
1313
import stripAnsi from 'strip-ansi';
1414
import {normalizeIcons} from './Utils';
1515

@@ -39,7 +39,7 @@ function spawnJest(
3939
args?: Array<string>,
4040
options?: RunJestOptions,
4141
spawnAsync?: false,
42-
): ExecaReturns;
42+
): ExecaReturnValue;
4343
function spawnJest(
4444
dir: string,
4545
args?: Array<string>,
@@ -53,7 +53,7 @@ function spawnJest(
5353
args?: Array<string>,
5454
options: RunJestOptions = {},
5555
spawnAsync: boolean = false,
56-
): ExecaReturnValue | ExecaChildProcess {
56+
): ExecaSyncReturnValue | ExecaChildProcess {
5757
const isRelative = !path.isAbsolute(dir);
5858

5959
if (isRelative) {
@@ -91,15 +91,15 @@ function spawnJest(
9191
);
9292
}
9393

94-
type RunJestResult = ExecaReturns & {
94+
interface RunJestResult extends ExecaReturnValue {
9595
status?: number;
9696
code?: number;
9797
json?: (
9898
dir: string,
9999
args: Array<string> | undefined,
100100
options: RunJestOptions,
101101
) => RunJestResult;
102-
};
102+
}
103103

104104
function normalizeResult(result: RunJestResult, options: RunJestOptions) {
105105
// For compat with cross-spawn

packages/jest-changed-files/src/git.ts

+10-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88

99
import * as path from 'path';
10-
import execa from 'execa';
10+
import execa, {ExecaReturnValue} from 'execa';
1111
import {Config} from '@jest/types';
1212

1313
import {SCMAdapter} from './types';
@@ -16,7 +16,15 @@ const findChangedFilesUsingCommand = async (
1616
args: Array<string>,
1717
cwd: Config.Path,
1818
): Promise<Array<Config.Path>> => {
19-
const result = await execa('git', args, {cwd});
19+
let result: ExecaReturnValue;
20+
21+
try {
22+
result = await execa('git', args, {cwd});
23+
} catch (e) {
24+
e.message = e.stderr + '\n\n' + e.message;
25+
26+
throw e;
27+
}
2028

2129
return result.stdout
2230
.split('\n')

packages/jest-changed-files/src/hg.ts

+10-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88

99
import * as path from 'path';
10-
import execa from 'execa';
10+
import execa, {ExecaReturnValue} from 'execa';
1111
import {Config} from '@jest/types';
1212

1313
import {SCMAdapter} from './types';
@@ -29,7 +29,15 @@ const adapter: SCMAdapter = {
2929
}
3030
args.push(...includePaths);
3131

32-
const result = await execa('hg', args, {cwd, env});
32+
let result: ExecaReturnValue;
33+
34+
try {
35+
result = await execa('hg', args, {cwd, env});
36+
} catch (e) {
37+
e.message = e.stderr + '\n\n' + e.message;
38+
39+
throw e;
40+
}
3341

3442
return result.stdout
3543
.split('\n')

0 commit comments

Comments
 (0)