Skip to content

Commit ad2df90

Browse files
committed
feat: Support destructuring in StatusSummary.
This change enables calling the `isClean` method from `git.status` without the `StatusSummary` context (ie: when destructured): ```typescript const { isClean } = await simpleGit().status(); expect( isClean() ).toBe( true ); ```
1 parent 7d198fa commit ad2df90

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

simple-git/src/lib/responses/StatusSummary.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export class StatusSummary implements StatusResult {
2020
public tracking = null;
2121
public detached = false;
2222

23-
public isClean(): boolean {
23+
public isClean = () => {
2424
return !this.files.length;
2525
}
2626
}

simple-git/test/unit/status.spec.ts

+5
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,11 @@ R src/a.txt -> src/c.txt
290290
expect(parseStatusSummary(`${type} file-name.foo`).isClean()).toBe(false);
291291
});
292292

293+
it('allows isClean to be destructured', () => {
294+
const { isClean } = parseStatusSummary('\n');
295+
expect(isClean()).toBe(true);
296+
});
297+
293298
it('reports empty response as a clean branch', () => {
294299
const statusSummary = parseStatusSummary('\n');
295300

0 commit comments

Comments
 (0)