Skip to content

Commit 8c28a9e

Browse files
authored
deno: handle peer deps with multiple peers (#465)
* deno: handle peer deps with multiple peers * deno: bump flatpak generator
1 parent 6fa9649 commit 8c28a9e

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

deno/deno.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@flatpak-contrib/flatpak-deno-generator",
3-
"version": "1.3.1",
3+
"version": "1.3.2",
44
"exports": "./src/main.ts",
55
"license": "MIT"
66
}

deno/src/main.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -221,17 +221,12 @@ export async function main(
221221
) => (val.os === undefined || val.os?.at(0) === "linux"))
222222
// deno-lint-ignore no-explicit-any
223223
.map(([key, val]: [string, any]) => {
224-
let r = splitOnce(key, "@", "right");
225-
// hande peer deps
226-
if (/_.+$/.test(r[0])) {
227-
const actualModule = splitOnce(r[0], "_", "right")[0];
228-
r = splitOnce(actualModule, "@", "right");
229-
}
230-
const name = r[0].includes("/") ? r[0].split("/")[1] : r[0];
224+
const r = key.match(/(^@?.+?)@([^_]+?)(?=_|$)/)!;
225+
const name = r[1].includes("/") ? r[1].split("/")[1] : r[1];
231226
const cpu = val.cpu?.at(0);
232227
return {
233-
module: r[0],
234-
version: r[1],
228+
module: r[1],
229+
version: r[2],
235230
name,
236231
cpu: cpu === "x64" ? "x86_64" : cpu === "arm64" ? "aarch64" : cpu,
237232
};

deno/tests/main_function.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,18 @@ Deno.test("main function: generates deno-sources.json from lockfile", async () =
4040
],
4141
"bin": true,
4242
},
43+
// peer deps can have multiple peers
44+
45+
{
46+
"integrity":
47+
"sha512-J/Nmb2Q2y7mck2hyCX4ckVHcR5tu2J+MtBEQqpDrrgELZ2uvraQcK/ioCV61AqkdXFgriksOKIceDcQmqnGhVw==",
48+
"dependencies": [
49+
"@sveltejs/vite-plugin-svelte",
50+
"debug",
51+
"svelte",
52+
"vite",
53+
],
54+
},
4355
},
4456
remote: {
4557
"https://deno.land/[email protected]/uuid/v1.ts":

0 commit comments

Comments
 (0)