Skip to content
Merged
Show file tree
Hide file tree
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
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