• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pkgxdev / libpkgx / 7686417725

28 Jan 2024 02:29PM UTC coverage: 83.59% (-0.09%) from 83.677%
7686417725

Pull #63

github

web-flow
Merge fec0d09fb into 653cd582e
Pull Request #63: deno 1.4.0

522 of 704 branches covered (0.0%)

Branch coverage included in aggregate %.

2244 of 2605 relevant lines covered (86.14%)

1181.7 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

81.82
/src/utils/pkg.ts
1
import { Package, PackageRequirement } from "../types.ts"
2
import * as semver from "./semver.ts"
51✔
3

4
/// allows inputs `nodejs.org@16` when `semver.parse` would reject
3✔
5
export function parse(input: string): PackageRequirement {
51✔
6
  input = input.trim()
69✔
7

8
  const match = input.match(/^(.+?)([\^=~<>@].+)?$/)
69✔
9
  if (!match) throw new Error(`invalid pkgspec: ${input}`)
×
10
  if (!match[2]) match[2] = "*"
69✔
11

12
  const project = match[1]
69✔
13
  const constraint = new semver.Range(match[2])
69✔
14
  return { project, constraint }
276✔
15
}
69✔
16

17
export function compare(a: Package, b: Package): number {
51✔
18
  return a.project === b.project
57✔
19
    ? a.version.compare(b.version)
57✔
20
    : a.project.localeCompare(b.project)
57✔
21
}
57✔
22

23
export function str(pkg: Package | PackageRequirement): string {
51✔
24
  if (!("constraint" in pkg)) {
96✔
25
    return `${pkg.project}=${pkg.version}`
153✔
26
  } else if (pkg.constraint.set === "*") {
×
27
    return pkg.project
×
28
  } else {
×
29
    return `${pkg.project}${pkg.constraint}`
162✔
30
  }
162✔
31
}
96✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc