MCPcopy Create free account
hub / github.com/GnomeSnapExtensions/gSnap / ShellVersion

Class ShellVersion

src/extension/shellversion.ts:26–71  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

24 * ShellVersion is used to parse the version string
25 */
26export class ShellVersion {
27 readonly major: number;
28 readonly minor: number;
29 private readonly rawVersion: string;
30
31 private constructor(version: string) {
32 const parts = version.split('.').map((part) => Number(part));
33 if (parts.length < 2) {
34 throw new Error(`invalid version supplied: ${version}`);
35 }
36 this.major = parts[0];
37 this.minor = parts[1];
38 // Tolerate "40.alpha.1" for example. See https://github.com/gSnap/gSnap/issues/187.
39 if (isNaN(this.minor)) {
40 this.minor = 0;
41 }
42 if (isNaN(this.major)) {
43 throw new Error(`invalid version supplied: ${JSON.stringify(version)}; got major = ${this.major}, minor = ${this.minor}`);
44 }
45 this.rawVersion = version;
46 }
47
48 public static defaultVersion(): ShellVersion {
49 return ShellVersion.parse(Config.PACKAGE_VERSION);
50 }
51
52 public static parse(version: string): ShellVersion {
53 return new ShellVersion(version);
54 }
55
56 version_at_least_34(): boolean {
57 return versionGreaterThanOrEqualTo(this, VERSION_34);
58 }
59
60 version_at_least_36(): boolean {
61 return versionGreaterThanOrEqualTo(this, VERSION_36);
62 }
63
64 version_at_least_41(): boolean {
65 return versionGreaterThanOrEqualTo(this, VERSION_41);
66 }
67
68 print_version () {
69 log("Init gnome-shell version " + this.rawVersion + " major " + this.major + " minor " + this.minor);
70 }
71};
72
73/**
74 * Returns true if a is >= b.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected