Skip to content

Commit

Permalink
fix: handle error when diffing lockfiles
Browse files Browse the repository at this point in the history
  • Loading branch information
mefengl committed Jul 15, 2023
1 parent a97b0c2 commit 1214d25
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,15 @@ async function processGitOperation(title: string, operation: (commitMsg: string)
await gitHelper.add('.');
const diffFiles = (await gitHelper.diff(['--name-only', '--staged'])).split('\n');
const changedLockfiles = checkLockfiles(diffFiles);
const diff = await gitHelper.diff(['--staged', ...changedLockfiles.map(lockfile => `:!${lockfile}`)]);
const gitInfo = getGitInfo({ diff, changedLockfiles });
let diff = '';
let gitInfo = '';
try {
diff = await gitHelper.diff(['--staged', ...changedLockfiles.map(lockfile => `:!${lockfile}`)]);
gitInfo = getGitInfo({ diff, changedLockfiles });
} catch (e) {
diff = await gitHelper.diff(['--staged']);
gitInfo = getGitInfo({ diff, changedLockfiles: [] });
}
if (!gitInfo) {
vscode.window.showInformationMessage(i18n.t('no-changes-to-commit'));
return;
Expand Down

0 comments on commit 1214d25

Please sign in to comment.