Skip to content

Commit

Permalink
Use semver to compare versions
Browse files Browse the repository at this point in the history
  • Loading branch information
msujew committed Jan 17, 2022
1 parent 74db1db commit cdaee64
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 116 deletions.
69 changes: 0 additions & 69 deletions packages/vsx-registry/src/common/vsx-version.spec.ts

This file was deleted.

41 changes: 0 additions & 41 deletions packages/vsx-registry/src/common/vsx-version.ts

This file was deleted.

11 changes: 5 additions & 6 deletions packages/vsx-registry/src/node/vsx-extension-resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import * as os from 'os';
import * as path from 'path';
import * as semver from 'semver';
import * as fs from '@theia/core/shared/fs-extra';
import { v4 as uuidv4 } from 'uuid';
import * as requestretry from 'requestretry';
Expand All @@ -25,7 +26,6 @@ import { PluginDeployerHandler, PluginDeployerResolver, PluginDeployerResolverCo
import { VSXExtensionUri } from '../common/vsx-extension-uri';
import { OVSXClientProvider } from '../common/ovsx-client-provider';
import { VSXExtensionRaw } from '@theia/ovsx-client';
import { compareVersion, parseVersion } from '../common/vsx-version';

@injectable()
export class VSXExtensionResolver implements PluginDeployerResolver {
Expand Down Expand Up @@ -85,11 +85,10 @@ export class VSXExtensionResolver implements PluginDeployerResolver {
protected hasSameOrNewerVersion(id: string, extension: VSXExtensionRaw): string | undefined {
const existingPlugin = this.pluginDeployerHandler.getDeployedPlugin(id);
if (existingPlugin) {
const version = parseVersion(extension.version);
const modelVersion = existingPlugin.metadata.model.version;
const existingVersion = parseVersion(modelVersion);
if (version && existingVersion && compareVersion(existingVersion, version) >= 0) {
return modelVersion;
const existingVersion = semver.clean(existingPlugin.metadata.model.version);
const desiredVersion = semver.clean(extension.version);
if (desiredVersion && existingVersion && semver.gte(existingVersion, desiredVersion)) {
return existingVersion;
}
}
return undefined;
Expand Down

0 comments on commit cdaee64

Please sign in to comment.