Skip to content

Commit 992804d

Browse files
committed
^0 != @0.0.0
1 parent 6a15172 commit 992804d

File tree

5 files changed

+31
-7
lines changed

5 files changed

+31
-7
lines changed

.github/deno-to-node.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import SemVer from "../src/utils/semver.ts";
55

66
await emptyDir("./dist");
77

8+
const test = !Deno.args.includes("--no-test");
9+
810
const version = (() => {
911
try {
1012
return new SemVer(Deno.args[0]).toString();
@@ -17,6 +19,7 @@ const version = (() => {
1719
await build({
1820
entryPoints: ["./mod.ts"],
1921
outDir: "./dist",
22+
test,
2023
shims: {
2124
deno: true,
2225
crypto: true,

.github/workflows/cd.npm.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
- published
77

88
concurrency:
9-
group: cd/vx/${{ github.event.release.tag_name }}
9+
group: cd/npm/${{ github.event.release.tag_name }}
1010
cancel-in-progress: true
1111

1212
permissions:

.github/workflows/cd.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
- uses: actions/checkout@v4
3636
- uses: pkgxdev/dev@v0
3737

38-
- run: deno task dnt ${{ inputs.version }}
38+
- run: deno task dnt ${{ inputs.version }} --no-test
3939

4040
- run: |
4141
mv dist libpkgx-${{inputs.version}}
@@ -45,9 +45,8 @@ jobs:
4545
run:
4646
gh release upload
4747
--clobber
48+
v${{ inputs.version }}
4849
libpkgx-${{ inputs.version }}.tar.xz
4950
env:
50-
# using this token rather than github.token due to `release not found` bug
51-
# https://github.com/cli/cli/issues/5252
52-
GH_TOKEN: ${{ secrets.TEMP_JACOBS_GITHUB_PAT }}
51+
GH_TOKEN: ${{ github.token }}
5352
GH_REPO: pkgxdev/libpkgx

src/utils/semver.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,20 @@ Deno.test("semver", async test => {
237237
assertFalse(a.satisfies(new SemVer("1.0.0")))
238238
})
239239

240+
await test.step("^0 string is not @0.0.0", () => {
241+
const a = new semver.Range("^0")
242+
assertEquals(a.toString(), "^0")
243+
244+
const b = new semver.Range("^0.0")
245+
assertEquals(b.toString(), "~0") //NOTE strictly should be ~0.0 but this is fine
246+
247+
const c = new semver.Range("^1")
248+
assertEquals(c.toString(), "^1")
249+
250+
const d = new semver.Range("^1.0")
251+
assertEquals(d.toString(), "^1")
252+
})
253+
240254
//FIXME this *should* work
241255
// await test.step("^11,^12…^11.3,^12.2", () => {
242256
// const a = new semver.Range("^11,^12")

src/utils/semver.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,17 @@ export class Range {
205205
return this.set.map(v => {
206206
if (!isArray(v)) return `=${v.toString()}`
207207
const [v1, v2] = v
208-
if (v1.major > 0 && v2.major == v1.major + 1 && v2.minor == 0 && v2.patch == 0) {
208+
if (v2.major == v1.major + 1 && v2.minor == 0 && v2.patch == 0) {
209209
const v = chomp(v1)
210-
return `^${v}`
210+
if (v1.major == 0) {
211+
if (v1.components.length == 1) {
212+
return `^0`
213+
} else {
214+
return `>=${v}<1`
215+
}
216+
} else {
217+
return `^${v}`
218+
}
211219
} else if (v2.major == v1.major && v2.minor == v1.minor + 1 && v2.patch == 0) {
212220
const v = chomp(v1)
213221
return `~${v}`

0 commit comments

Comments
 (0)