Skip to content

Commit 2e7a021

Browse files
authored
fix: dump with filter regression (#218)
1 parent ba9f1ec commit 2e7a021

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

__tests__/__snapshots__/dump.spec.ts.snap

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,12 @@ exports[`#dump() > with a glob pattern > should return files that matches the pa
4343
},
4444
}
4545
`;
46+
47+
exports[`#dump() > with custom filter > should match snapshot 1`] = `
48+
{
49+
"foo/not-committed": {
50+
"contents": "not-committed",
51+
"state": "modified",
52+
},
53+
}
54+
`;

__tests__/dump.spec.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ describe('#dump()', () => {
4242
expect(fs.dump(output)).toMatchSnapshot();
4343
});
4444

45+
describe('with custom filter', () => {
46+
it('should match snapshot', () => {
47+
expect(fs.dump(output, file => file.path.endsWith('not-committed'))).toMatchSnapshot();
48+
});
49+
});
50+
4551
describe('with a glob pattern', () => {
4652
it('should return files that matches the pattern and have state or stateCleared', () => {
4753
expect(fs.dump(output, '**/*committed')).toMatchSnapshot();

src/actions/dump.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export default function <EditorFile extends MemFsEditorFile>(
2121
const filterFile: (file: EditorFile, cwd: string) => boolean =
2222
typeof filter === 'string'
2323
? (file: MemFsEditorFile) => defaultDumpFilter(file) && minimatch(file.path, filter)
24-
: defaultDumpFilter;
24+
: filter ?? defaultDumpFilter;
2525

2626
return Object.fromEntries(
2727
this.store

0 commit comments

Comments
 (0)