Skip to content

Commit cad9a85

Browse files
committed
Add import.meta.main guard and export core functions in resolve-previous-release-tag.ts
1 parent b623a30 commit cad9a85

1 file changed

Lines changed: 14 additions & 12 deletions

File tree

scripts/resolve-previous-release-tag.ts

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ interface NightlyVersion {
2424
readonly runNumber: number;
2525
}
2626

27-
const parseNumericIdentifier = (identifier: string): number | undefined =>
27+
export const parseNumericIdentifier = (identifier: string): number | undefined =>
2828
/^\d+$/.test(identifier) ? Number(identifier) : undefined;
2929

30-
const comparePrereleaseIdentifiers = (left: string, right: string): number => {
30+
export const comparePrereleaseIdentifiers = (left: string, right: string): number => {
3131
const leftNumeric = parseNumericIdentifier(left);
3232
const rightNumeric = parseNumericIdentifier(right);
3333

@@ -43,7 +43,7 @@ const comparePrereleaseIdentifiers = (left: string, right: string): number => {
4343
return left.localeCompare(right);
4444
};
4545

46-
const compareStableVersions = (left: StableVersion, right: StableVersion): number => {
46+
export const compareStableVersions = (left: StableVersion, right: StableVersion): number => {
4747
if (left.major !== right.major) return left.major - right.major;
4848
if (left.minor !== right.minor) return left.minor - right.minor;
4949
if (left.patch !== right.patch) return left.patch - right.patch;
@@ -68,7 +68,7 @@ const compareStableVersions = (left: StableVersion, right: StableVersion): numbe
6868
return 0;
6969
};
7070

71-
const parseStableTag = (tag: string): StableVersion | undefined => {
71+
export const parseStableTag = (tag: string): StableVersion | undefined => {
7272
const match = /^v(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/.exec(tag);
7373
if (!match) return undefined;
7474

@@ -83,15 +83,15 @@ const parseStableTag = (tag: string): StableVersion | undefined => {
8383
};
8484
};
8585

86-
const compareNightlyVersions = (left: NightlyVersion, right: NightlyVersion): number => {
86+
export const compareNightlyVersions = (left: NightlyVersion, right: NightlyVersion): number => {
8787
if (left.major !== right.major) return left.major - right.major;
8888
if (left.minor !== right.minor) return left.minor - right.minor;
8989
if (left.patch !== right.patch) return left.patch - right.patch;
9090
if (left.date !== right.date) return left.date - right.date;
9191
return left.runNumber - right.runNumber;
9292
};
9393

94-
const parseNightlyTag = (tag: string): NightlyVersion | undefined => {
94+
export const parseNightlyTag = (tag: string): NightlyVersion | undefined => {
9595
const match = /^nightly-v(\d+)\.(\d+)\.(\d+)-nightly\.(\d{8})\.(\d+)$/.exec(tag);
9696
if (!match) return undefined;
9797

@@ -107,7 +107,7 @@ const parseNightlyTag = (tag: string): NightlyVersion | undefined => {
107107
};
108108
};
109109

110-
const resolvePreviousReleaseTag = (
110+
export const resolvePreviousReleaseTag = (
111111
channel: ReleaseChannel,
112112
currentTag: string,
113113
tags: ReadonlyArray<string>,
@@ -196,8 +196,10 @@ const command = Command.make(
196196
),
197197
).pipe(Command.withDescription("Resolve the previous release tag for a stable or nightly series."));
198198

199-
Command.run(command, { version: "0.0.0" }).pipe(
200-
Effect.scoped,
201-
Effect.provide(NodeServices.layer),
202-
NodeRuntime.runMain,
203-
);
199+
if (import.meta.main) {
200+
Command.run(command, { version: "0.0.0" }).pipe(
201+
Effect.scoped,
202+
Effect.provide(NodeServices.layer),
203+
NodeRuntime.runMain,
204+
);
205+
}

0 commit comments

Comments
 (0)