Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/hooks/usePantry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export default function usePantry() {
getProvides,
getInterpreter,
getRuntimeEnvironment,
available,
ls,
prefix: getPantryPrefix()
}
Expand Down Expand Up @@ -99,6 +100,14 @@ const getRuntimeEnvironment = async (pkg: Package): Promise<Record<string, strin
return expand_env_obj(obj, pkg, [])
}

const available = async (pkg: PackageRequirement): Promise<boolean> => {
let { platform } = await entry(pkg).yml()
if (!platform) return true
if (isString(platform)) platform = [platform]
if (!isArray(platform)) throw new Error("bad-yaml")
return platform.includes(host().platform) ||platform.includes(`${host().platform}/${host().arch}`)
}

function entry({ project }: { project: string }): Entry {
for (const prefix of pantry_paths()) {
if (!prefix.exists()) throw new TeaError('not-found: pantry', { path: prefix.parent() })
Expand Down