Skip to content

Commit

Permalink
chore: Add latestVersion field (optional) (#144)
Browse files Browse the repository at this point in the history
  • Loading branch information
kadirkaang authored Sep 16, 2024
1 parent f27469c commit ca0516e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions vscode/src/core/Item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export default class Item {
range: Range = new Range(0, 0, 0, 0);
decoRange: Range = new Range(0, 0, 0, 0);
lockedAt?: string;
latestVersion?: string;
constructor(item?: Item) {
if (item) {
this.key = item.key;
Expand Down
1 change: 1 addition & 0 deletions vscode/src/core/fetchers/NpmFetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export class NpmFetcher extends Fetcher {
.filter((i: string) => i !== "" && i !== undefined && !base.checkUnstables(Settings.npm.unstableFilter, i, dep.item.value!))
.sort(compareVersions).reverse();
dep.versions = versions;
dep.item.latestVersion = mod.latestVersion;
dep.item.value = dep.item.value === "latest" ? mod.latestVersion : dep.item.value;
return dep;
}).catch(fetcherCatch(dep));
Expand Down
5 changes: 4 additions & 1 deletion vscode/src/core/listeners/listener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ export abstract class Listener {
let cached = cache.get<Dependency>(dep.item.key + dep.item.range.start.line);
dep.item.value = dep.item.lockedAt ?? dep.item.value;
if (cached) {
if (dep.item.value === "latest") return cached;
if (dep.item.value === "latest") {
dep.item.value = cached.item.latestVersion
}
dep.item.latestVersion = cached.item.latestVersion;
cached.item = dep.item;
} else {
cache.set(dep.item.key + dep.item.range.start.line, dep);
Expand Down

0 comments on commit ca0516e

Please sign in to comment.