Skip to content

Commit

Permalink
supports if: darwin, if: aarch64, or if: darwin/aarch64
Browse files Browse the repository at this point in the history
next step would be to allow a `platform/arch && semver`. one thing at a time.
  • Loading branch information
jhheider authored and mxcl committed Oct 5, 2023
1 parent 94c0811 commit e9f8214
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/usePantry.getScript.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import useConfig from "libpkgx/hooks/useConfig.ts"
import { SupportedPlatforms } from "libpkgx/utils/host.ts"
import { SupportedPlatforms, SupportedArchitectures } from "libpkgx/utils/host.ts"
import { isArray, isString, isPlainObject, PlainObject } from "is-what"
import { Package, Installation, hooks, utils, semver } from "libpkgx"
import undent from "outdent"
Expand All @@ -23,6 +23,14 @@ export const getScript = async (pkg: Package, key: 'build' | 'test', deps: Insta
const condition = obj["if"]
if (condition) {
if (SupportedPlatforms.includes(condition) && host().platform != condition) return ''
if (SupportedArchitectures.includes(condition) && host().arch != condition) return ''
if (condition.includes("/")) {
const [platform, arch] = condition.split("/")
if (SupportedPlatforms.includes(platform) &&
SupportedArchitectures.includes(arch) &&
(host().platform != platform ||
host().arch != arch)) return ''
}

const range = semver.Range.parse(condition)
if (range && !range.satisfies(pkg.version)) return ''
Expand Down

0 comments on commit e9f8214

Please sign in to comment.