Skip to content

Commit 55caeb7

Browse files
committed
chore: remove unnecessary checks
1 parent 506a062 commit 55caeb7

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

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

+5-7
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,13 @@ const findChangedFilesUsingCommand = async (
3434

3535
const adapter: SCMAdapter = {
3636
findChangedFiles: async (cwd, options) => {
37-
const changedSince: string | undefined =
38-
options && (options.withAncestor ? 'HEAD^' : options.changedSince);
37+
const changedSince = options.withAncestor ? 'HEAD^' : options.changedSince;
3938

40-
const includePaths: Array<Config.Path> = (
41-
(options && options.includePaths) ||
42-
[]
43-
).map(absoluteRoot => path.normalize(path.relative(cwd, absoluteRoot)));
39+
const includePaths = (options.includePaths ?? []).map(absoluteRoot =>
40+
path.normalize(path.relative(cwd, absoluteRoot)),
41+
);
4442

45-
if (options && options.lastCommit) {
43+
if (options.lastCommit) {
4644
return findChangedFilesUsingCommand(
4745
['show', '--name-only', '--pretty=format:', 'HEAD', '--'].concat(
4846
includePaths,

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

+4-6
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,20 @@
88

99
import * as path from 'path';
1010
import execa = require('execa');
11-
import type {Config} from '@jest/types';
1211
import type {SCMAdapter} from './types';
1312

1413
const env = {...process.env, HGPLAIN: '1'};
1514

1615
const adapter: SCMAdapter = {
1716
findChangedFiles: async (cwd, options) => {
18-
const includePaths: Array<Config.Path> =
19-
(options && options.includePaths) || [];
17+
const includePaths = options.includePaths ?? [];
2018

2119
const args = ['status', '-amnu'];
22-
if (options && options.withAncestor) {
20+
if (options.withAncestor) {
2321
args.push('--rev', 'min((!public() & ::.)+.)^');
24-
} else if (options && options.changedSince) {
22+
} else if (options.changedSince) {
2523
args.push('--rev', `ancestor(., ${options.changedSince})`);
26-
} else if (options && options.lastCommit === true) {
24+
} else if (options.lastCommit === true) {
2725
args.push('--change', '.');
2826
}
2927
args.push(...includePaths);

0 commit comments

Comments
 (0)