Skip to content

Commit

Permalink
Don’t abort if a single entry cannot be parsed (#57)
Browse files Browse the repository at this point in the history
New deno requires `--allow-sys` for this but only brewkit needs this
  • Loading branch information
mxcl authored Jan 5, 2024
1 parent fe0614f commit fc63474
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 17 deletions.
15 changes: 0 additions & 15 deletions src/hooks/useMoustaches.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }]
Expand All @@ -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),
Expand All @@ -48,7 +35,6 @@ export default function() {
apply,
tokenize: {
version: tokenizeVersion,
host: tokenizeHost,
pkg: tokenizePackage
}
}
Expand All @@ -69,7 +55,6 @@ export default function() {
...tokenizePackage(pkg),
...pkgx(),
...base.tokenize.version(pkg.version),
...base.tokenize.host(),
]

return {
Expand Down
6 changes: 4 additions & 2 deletions src/hooks/usePantry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit fc63474

Please sign in to comment.