Skip to content

Commit

Permalink
[dev] Support symlinked keyfiles
Browse files Browse the repository at this point in the history
Fixes #890
  • Loading branch information
mxcl committed Jan 17, 2024
1 parent 246d637 commit e8ecc07
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 16 deletions.
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 e8ecc07

Please sign in to comment.