Skip to content

Commit

Permalink
[dev] Support symlinked keyfiles (#932)
Browse files Browse the repository at this point in the history
Fixes #890
  • Loading branch information
mxcl authored Jan 17, 2024
1 parent 246d637 commit b41c812
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 17 deletions.
4 changes: 3 additions & 1 deletion deno.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
"run": "deno run --unstable -A ./entrypoint.ts",

// you can specify paths to specific tests if you need
"test": "deno test --allow-read=$PWD,$TMPDIR,$HOME,/ --allow-env --allow-write=$TMPDIR --allow-ffi --unstable",
// follows is the ideal permissions lines, unfortunately deno considers making symlinks to require full read/write permissions for fuck knows why reasons
//"test": "deno test --allow-read=$PWD,$TMPDIR,$HOME,/ --allow-env --allow-write=$TMPDIR --allow-ffi --unstable",
"test": "deno test --allow-read --allow-env --allow-write --allow-ffi --unstable",
// ^^ ffi & unstable needed for execve.ts

// installs to /usr/local/bin/pkgx
Expand Down
2 changes: 1 addition & 1 deletion src/modes/internal.activate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Deno.test("internal.activate.ts", async runner => {
_internals.datadir()
})

await runner.step("apply_userenv", () => {
await runner.step("apply userenv", () => {
const userenv = { PATH: "/foo/bar:$PATH" }
const env = { PATH: "/baz:$PATH"}
_internals.apply_userenv(env, userenv)
Expand Down
31 changes: 18 additions & 13 deletions src/utils/devenv.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,26 @@ Deno.test("devenv.ts", async runner => {

for (const [keyfile, dep] of keyfiles) {
await test.step(`${keyfile}`, async () => {
const file = fixturesd.join(keyfile).cp({ into: Path.mktemp() })
const { env, pkgs } = await specimen(file.parent())
assert(pkgs.find(pkg => utils.pkg.str(pkg) == "zlib.net^1.2"), "should dep zlib^1.2")
if (dep) {
assert(pkgs.find(pkg => utils.pkg.str(pkg) == dep), `should dep ${dep}`)
const go = async (file: Path) => {
const { env, pkgs } = await specimen(file.parent())
assert(pkgs.find(pkg => utils.pkg.str(pkg) == "zlib.net^1.2"), "should dep zlib^1.2")
if (dep) {
assert(pkgs.find(pkg => utils.pkg.str(pkg) == dep), `should dep ${dep}`)
}

switch (keyfile) {
case 'package.json/str/package.json':
case 'package.json/arr/package.json':
case 'deno.json/arr/deno.json':
break // testing the short form for deps with these files
default:
assertEquals(env.FOO, "BAR")
}
}

switch (keyfile) {
case 'package.json/str/package.json':
case 'package.json/arr/package.json':
case 'deno.json/arr/deno.json':
break // testing the short form for deps with these files
default:
assertEquals(env.FOO, "BAR")
}
const target = fixturesd.join(keyfile).cp({ into: Path.mktemp() })
await go(target)
await go(Path.mktemp().join(target.basename()).ln('s', { target }))
})
}
})
Expand Down
4 changes: 2 additions & 2 deletions src/utils/devenv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ export default async function(dir: Path) {
const pkgs: PackageRequirement[] = []
const env: Record<string, string> = {}

for await (const [path, {name, isFile, isDirectory}] of dir.ls()) {
if (isFile) {
for await (const [path, {name, isFile, isSymlink, isDirectory}] of dir.ls()) {
if (isFile || isSymlink) {
switch (name) {
case "deno.json":
case "deno.jsonc":
Expand Down

0 comments on commit b41c812

Please sign in to comment.