Skip to content

Commit

Permalink
fix(cli): don't crash when there are no changes (#334)
Browse files Browse the repository at this point in the history
code-suggester CLI is trying to parse an empty string as a valid file diff and crashing.

Fixes #229
  • Loading branch information
chingor13 committed Feb 23, 2022
1 parent 2d5c3f9 commit e606126
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/bin/handle-git-dir-change.ts
Expand Up @@ -147,7 +147,8 @@ export function getAllDiffs(gitRootDir: string): string[] {
})
.toString() // strictly return buffer for mocking purposes. sinon ts doesn't infer {encoding: 'utf-8'}
.trimRight() // remove the trailing new line
.split('\n');
.split('\n')
.filter(line => !!line.trim());
execSync('git reset .', {cwd: gitRootDir});
return diffs;
}
Expand Down

0 comments on commit e606126

Please sign in to comment.