Skip to content

Commit

Permalink
refactor: Improve validation logic in TomlLockParser (#128)
Browse files Browse the repository at this point in the history
  • Loading branch information
kadirkaang authored Sep 6, 2024
1 parent ff55b9c commit 2d69e90
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion vscode/src/core/parsers/TomlLockParser.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { satisfies } from "semver";
import Item from "../Item";

export class State {
Expand Down Expand Up @@ -44,7 +45,11 @@ export class TomlLockFileParser {

setLockValue(state: State, items: Item[]): void {
let foundItem = items.find((item) => item.key === state.dependency);
if (foundItem) {
if (
foundItem &&
(!foundItem.lockedAt ||
(foundItem.value && satisfies(state.lockedValue, foundItem.value)))
) {
foundItem.lockedAt = state.lockedValue;
}
state.lockedValue = "";
Expand Down

0 comments on commit 2d69e90

Please sign in to comment.