forked from pkgxdev/pkgx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhacks.ts
47 lines (40 loc) · 1.41 KB
/
hacks.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { PackageRequirement } from "types"
import { PlainObject } from "is_what"
import { host, validate_str } from "utils"
import { isString, isNumber } from "is_what"
import * as semver from "semver"
export function validatePackageRequirement(input: PlainObject): PackageRequirement | undefined {
let { constraint, project } = input
if (host().platform == 'darwin' && (project == "apple.com/xcode/clt" || project == "tea.xyz/gx/make")) {
// Apple will error out and prompt the user to install
//NOTE what we would really like is to error out when this dependency is *used*
// this is not the right place to error that. so FIXME
return // compact this dep away
}
if (host().platform == 'linux' && project == "tea.xyz/gx/make") {
project = "gnu.org/make"
constraint = '*'
}
validate_str(project)
//HACKS
if (constraint == 'c99' && project == 'tea.xyz/gx/cc') {
constraint = '^0.1'
}
if (constraint === undefined) {
constraint = '*'
} else if (isNumber(constraint)) {
//FIXME change all pantry entries to use proper syntax
constraint = `^${constraint}`
}
if (!isString(constraint)) {
throw new Error(`invalid constraint: ${constraint}`)
} else if (/^\d/.test(constraint)) {
//FIXME change all pantry entries to use proper syntax
constraint = `^${constraint}`
}
constraint = new semver.Range(constraint)
return {
project,
constraint
}
}