Overlay ourselves before building

/opt is for builds, don’t run your main tea out of it
This commit is contained in:
Max Howell 2022-10-27 10:59:31 -04:00
parent 77a44f7424
commit 6d6ccf652b
5 changed files with 20 additions and 4 deletions

View file

@ -77,6 +77,6 @@ scripts/ls.ts | xargs scripts/sort.ts | xargs scripts/build.ts
```sh ```sh
for x in scripts/*.ts src/app.ts; do for x in scripts/*.ts src/app.ts; do
deno check --import-map=$SRCROOT/import-map.json $x deno check --unstable --import-map=$SRCROOT/import-map.json $x
done done
``` ```

View file

@ -22,4 +22,3 @@ test:
test "$OUT" = "$INPUT" test "$OUT" = "$INPUT"
env: env:
INPUT: Hello, World! INPUT: Hello, World!

View file

@ -38,6 +38,8 @@ if (usePrefix().string != "/opt") {
throw new Error("builds must be performed in /opt (try TEA_PREFIX=/opt)") throw new Error("builds must be performed in /opt (try TEA_PREFIX=/opt)")
} }
await overlay()
for (const rq of dry) { for (const rq of dry) {
const pkg = await pantry.resolve(rq) const pkg = await pantry.resolve(rq)
@ -64,3 +66,17 @@ await set_output("srcs-relative-paths", rv.compact(x => x.src?.relative({ to }))
interface InstallationPlus extends Installation { interface InstallationPlus extends Installation {
src: Path src: Path
} }
///------------------------------------------------------------
/// overlay ourselves onto the /opt pantry
async function overlay() {
const pantry_prefix = usePrefix().join("tea.xyz/var/pantry")
const self = new URL(import.meta.url).path().join("../../projects")
const to = pantry_prefix.join("projects")
for await (const [path, {isFile}] of self.walk()) {
if (isFile) {
const dst = to.join(path.relative({ to: self }))
path.cp({ into: dst.parent().mkpath() })
}
}
}

View file

@ -2,7 +2,7 @@ import { useCellar, usePantry, usePrefix } from "hooks"
import { link, hydrate } from "prefab" import { link, hydrate } from "prefab"
import { Installation, Package } from "types" import { Installation, Package } from "types"
import useShellEnv, { expand } from "hooks/useShellEnv.ts" import useShellEnv, { expand } from "hooks/useShellEnv.ts"
import { run, undent, host, tuplize, panic } from "utils" import { run, undent, host, tuplize } from "utils"
import { str as pkgstr } from "utils/pkg.ts" import { str as pkgstr } from "utils/pkg.ts"
import fix_pkg_config_files from "./fix-pkg-config-files.ts" import fix_pkg_config_files from "./fix-pkg-config-files.ts"
import Path from "path" import Path from "path"

View file

@ -9,6 +9,7 @@ args:
- --allow-read - --allow-read
- --allow-write - --allow-write
- --allow-env - --allow-env
- --unstable
- --import-map={{ srcroot }}/import-map.json - --import-map={{ srcroot }}/import-map.json
---*/ ---*/
@ -20,7 +21,7 @@ import { resolve, install, hydrate, link } from "prefab"
import Path from "path" import Path from "path"
import * as ARGV from "./utils/args.ts" import * as ARGV from "./utils/args.ts"
const { debug } = useFlags() useFlags()
const pantry = usePantry() const pantry = usePantry()