Skip to content

Commit fc63474

Browse files
authored
Don’t abort if a single entry cannot be parsed (#57)
New deno requires `--allow-sys` for this but only brewkit needs this
1 parent fe0614f commit fc63474

File tree

2 files changed

+4
-17
lines changed

2 files changed

+4
-17
lines changed

src/hooks/useMoustaches.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ import { Package, Installation } from "../types.ts"
22
import SemVer from "../utils/semver.ts"
33
import useConfig from "./useConfig.ts"
44
import useCellar from "./useCellar.ts"
5-
import host from "../utils/host.ts"
6-
import * as os from "node:os"
75

86
function tokenizePackage(pkg: Package) {
97
return [{ from: "prefix", to: useCellar().keg(pkg).string }]
@@ -25,17 +23,6 @@ function tokenizeVersion(version: SemVer, prefix = 'version') {
2523
return rv
2624
}
2725

28-
//TODO replace `hw` with `host`
29-
function tokenizeHost() {
30-
const { arch, target, platform } = host()
31-
return [
32-
{ from: "hw.arch", to: arch },
33-
{ from: "hw.target", to: target },
34-
{ from: "hw.platform", to: platform },
35-
{ from: "hw.concurrency", to: os.cpus().length.toString() }
36-
]
37-
}
38-
3926
function apply(input: string, map: { from: string, to: string }[]) {
4027
return map.reduce((acc, {from, to}) =>
4128
acc.replace(new RegExp(`(^\\$)?{{\\s*${from}\\s*}}`, "g"), to),
@@ -48,7 +35,6 @@ export default function() {
4835
apply,
4936
tokenize: {
5037
version: tokenizeVersion,
51-
host: tokenizeHost,
5238
pkg: tokenizePackage
5339
}
5440
}
@@ -69,7 +55,6 @@ export default function() {
6955
...tokenizePackage(pkg),
7056
...pkgx(),
7157
...base.tokenize.version(pkg.version),
72-
...base.tokenize.host(),
7358
]
7459

7560
return {

src/hooks/usePantry.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,10 @@ export default function usePantry() {
174174
rv.push(proj)
175175
continue
176176
}
177-
const yaml = await proj.yaml()
178-
if (yaml["display-name"]?.toLowerCase() == name) {
177+
const yaml = await proj.yaml().swallow()
178+
if (!yaml) {
179+
console.warn("warn: parse failure:", pkg.project)
180+
} else if (yaml["display-name"]?.toLowerCase() == name) {
179181
rv.push(proj)
180182
} else if ((await proj.provides()).map(x => x.toLowerCase()).includes(name)) {
181183
rv.push(proj)

0 commit comments

Comments
 (0)