From fc6347457192231113a11536bf80037c559e3681 Mon Sep 17 00:00:00 2001 From: Max Howell Date: Fri, 5 Jan 2024 12:50:10 +0000 Subject: [PATCH] =?UTF-8?q?Don=E2=80=99t=20abort=20if=20a=20single=20entry?= =?UTF-8?q?=20cannot=20be=20parsed=20(#57)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit New deno requires `--allow-sys` for this but only brewkit needs this --- src/hooks/useMoustaches.ts | 15 --------------- src/hooks/usePantry.ts | 6 ++++-- 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/src/hooks/useMoustaches.ts b/src/hooks/useMoustaches.ts index 261bb43..116cbf7 100644 --- a/src/hooks/useMoustaches.ts +++ b/src/hooks/useMoustaches.ts @@ -2,8 +2,6 @@ import { Package, Installation } from "../types.ts" import SemVer from "../utils/semver.ts" import useConfig from "./useConfig.ts" import useCellar from "./useCellar.ts" -import host from "../utils/host.ts" -import * as os from "node:os" function tokenizePackage(pkg: Package) { return [{ from: "prefix", to: useCellar().keg(pkg).string }] @@ -25,17 +23,6 @@ function tokenizeVersion(version: SemVer, prefix = 'version') { return rv } -//TODO replace `hw` with `host` -function tokenizeHost() { - const { arch, target, platform } = host() - return [ - { from: "hw.arch", to: arch }, - { from: "hw.target", to: target }, - { from: "hw.platform", to: platform }, - { from: "hw.concurrency", to: os.cpus().length.toString() } - ] -} - function apply(input: string, map: { from: string, to: string }[]) { return map.reduce((acc, {from, to}) => acc.replace(new RegExp(`(^\\$)?{{\\s*${from}\\s*}}`, "g"), to), @@ -48,7 +35,6 @@ export default function() { apply, tokenize: { version: tokenizeVersion, - host: tokenizeHost, pkg: tokenizePackage } } @@ -69,7 +55,6 @@ export default function() { ...tokenizePackage(pkg), ...pkgx(), ...base.tokenize.version(pkg.version), - ...base.tokenize.host(), ] return { diff --git a/src/hooks/usePantry.ts b/src/hooks/usePantry.ts index 3317954..8b96da2 100644 --- a/src/hooks/usePantry.ts +++ b/src/hooks/usePantry.ts @@ -174,8 +174,10 @@ export default function usePantry() { rv.push(proj) continue } - const yaml = await proj.yaml() - if (yaml["display-name"]?.toLowerCase() == name) { + const yaml = await proj.yaml().swallow() + if (!yaml) { + console.warn("warn: parse failure:", pkg.project) + } else if (yaml["display-name"]?.toLowerCase() == name) { rv.push(proj) } else if ((await proj.provides()).map(x => x.toLowerCase()).includes(name)) { rv.push(proj)