-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
10 changed files
with
263 additions
and
12 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const nodeSnapshotImpl = "node:internal/test_runner/snapshot"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
export const enum Capability { | ||
ExperimentalSnapshots = 1 << 0, | ||
} | ||
|
||
export class NodeVersion { | ||
private readonly capabilities = 0; | ||
|
||
public static process() { | ||
const version = process.versions.node.split(".").map(Number); | ||
return new NodeVersion(new Semver(version[0], version[1], version[2])); | ||
} | ||
|
||
constructor(public readonly semver: Semver) { | ||
// todo@connor4312: currently still experimental in 23, if it's extended | ||
// to stable 24 then then should be updated to lt(new Semver(25, 0, 0)) | ||
if (semver.gte(new Semver(22, 3, 0)) && semver.lt(new Semver(24, 0, 0))) { | ||
this.capabilities |= Capability.ExperimentalSnapshots; | ||
} | ||
} | ||
|
||
public has(capability: Capability) { | ||
return (this.capabilities & capability) !== 0; | ||
} | ||
} | ||
|
||
class Semver { | ||
constructor( | ||
public readonly major: number, | ||
public readonly minor: number, | ||
public readonly patch: number, | ||
) {} | ||
|
||
public compare(other: Semver) { | ||
return this.major - other.major || this.minor - other.minor || this.patch - other.patch; | ||
} | ||
|
||
public gt(other: Semver) { | ||
return this.compare(other) > 0; | ||
} | ||
|
||
public gte(other: Semver) { | ||
return this.compare(other) >= 0; | ||
} | ||
|
||
public lt(other: Semver) { | ||
return this.compare(other) < 0; | ||
} | ||
|
||
public lte(other: Semver) { | ||
return this.compare(other) <= 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.