Skip to content
Closed
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
12 changes: 7 additions & 5 deletions src/hooks/useVirtualEnv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,13 @@ export default async function(cwd: Path): Promise<VirtualEnv> {
}
if (_if("action.yml", "action.yaml")) {
const yaml = validate.obj(await f!.readYAML())
const [,v] = yaml.runs?.using.match(/node(\d+)/) ?? []
pkgs.push({
project: "nodejs.org",
constraint: new semver.Range(`^${v}`)
})
const match = yaml.runs?.using.match(/node(\d+)/)
if(match) {
pkgs.push({
project: "nodejs.org",
constraint: new semver.Range(`^${match[1]}`)
})
}
}
if (_if("cargo.toml")) {
pkgs.push({project: "rust-lang.org", constraint})
Expand Down
2 changes: 2 additions & 0 deletions tests/fixtures/no-version/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
runs:
using: docker
19 changes: 19 additions & 0 deletions tests/functional/devenv.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,25 @@ Deno.test("should provide python in dev env", { sanitizeResources: false, saniti
}
})

Deno.test("tolerant package parsing", { sanitizeResources: false, sanitizeOps: false }, async test => {
const SHELL = "/bin/zsh"

const tests = [
{ file: "no-version/action.yml", pkg: [] },
]

for (const {file, pkg} of tests) {
await test.step(file, async () => {
const {run, teaDir } = await createTestHarness()

fixturesDir.join(file).cp({into: teaDir})
const { stdout } = await run(["+tea.xyz/magic", "-Esk", "--chaste", "env"], { env: { SHELL, obj: {} } })

assertEquals(getTeaPackages(SHELL, stdout), pkg, "should match expected packages")
})
}
})

Deno.test("tolerant .node-version parsing", { sanitizeResources: false, sanitizeOps: false }, async test => {
const SHELL = "/bin/zsh"

Expand Down