Skip to content

Commit

Permalink
Fixes pkgxdev#774
Browse files Browse the repository at this point in the history
  • Loading branch information
mxcl committed Oct 20, 2023
1 parent c0a71ce commit 656585b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion deno.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
//--------------------------------------- ci/cd/admin
"coverage" : "scripts/run-coverage.sh",
"typecheck": "deno check --unstable ./entrypoint.ts",
"compile": "deno compile --allow-read --allow-write --allow-net --allow-run --allow-env --allow-ffi --unstable --output $INIT_CWD/pkgx ./entrypoint.ts"
"compile": "deno compile --lock=deno.lock --allow-read --allow-write --allow-net --allow-run --allow-env --allow-ffi --unstable --output $INIT_CWD/pkgx ./entrypoint.ts"
},
"pkgx": {
"dependencies": {
Expand Down
4 changes: 3 additions & 1 deletion src/utils/devenv.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,16 @@ Deno.test("devenv.ts", async runner => {
[".ruby-version", "[email protected]"],
["yarn.lock", "yarnpkg.com"],
["bun.lockb", "bun.sh>=1"],
["pyproject.toml/poetry-yaml-fm/pyproject.toml", "pip.pypa.io", "python.org~3.10"],
["pyproject.toml/poetry-yaml-fm/pyproject.toml", "pip.pypa.io", "python~3.10"],
]

for (const [keyfile, ...deps] of keyfiles) {
await test.step(keyfile, async () => {
const file = fixturesd.join(keyfile).cp({ into: Path.mktemp() })
const { env, pkgs } = await specimen(file.parent())

assertEquals(pkgs.length, deps.length)

pkgs.forEach((pkg, i) => {
assertEquals(Object.keys(env).length, 0);
assertEquals(utils.pkg.str(pkg), deps[i]);
Expand Down
4 changes: 3 additions & 1 deletion src/utils/devenv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,9 @@ export default async function(dir: Path) {
if (/^((#|\/\/)\s*)?---(\s*\*\/)?$/.test(line.trim())) {
let node = parseYaml(yaml)
/// using a `pkgx` node is safer (YAML-FM is a free-for-all) but is not required
if (isPlainObject(node) && node.pkgx) node = node.pkgx
if (isPlainObject(node) && node.pkgx) {
node = isString(node.pkgx) || isArray(node.pkgx) ? { dependencies: node.pkgx } : node.pkgx
}
return await parse_well_formatted_node(node)
}
yaml += line?.replace(/^(#|\/\/)/, '')
Expand Down

0 comments on commit 656585b

Please sign in to comment.