Skip to content

Commit

Permalink
base: add removeNodeModules.
Browse files Browse the repository at this point in the history
  • Loading branch information
dajiaji committed Nov 16, 2024
1 parent be92b88 commit afb9808
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 18 deletions.
6 changes: 4 additions & 2 deletions packages/chacha20poly1305/dnt.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { build, emptyDir } from "@deno/dnt";
import { copySync } from "@std/fs";
import { removeNodeModules } from "../../utils/misc.ts";

// clean up dist
await emptyDir("../../npm/packages/chacha20poly1305");
await emptyDir("../../npm/samples/chacha20poly1305");
await emptyDir("../../npm/test/chacha20poly1305/runtimes/cloudflare");

await emptyDir("test/runtimes/browsers/node_modules");
await emptyDir("test/runtimes/bun/node_modules");
// clean up node_modules
await removeNodeModules();

const denoPkg = JSON.parse(await Deno.readTextFile("./deno.json"));

Expand Down
6 changes: 4 additions & 2 deletions packages/core/dnt.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { build, emptyDir } from "@deno/dnt";
import { copySync } from "@std/fs";
import { removeNodeModules } from "../../utils/misc.ts";

// clean up dist
await emptyDir("../../npm/packages/core");
await emptyDir("../../npm/samples/core");
await emptyDir("../../npm/test/core/runtimes/cloudflare");

await emptyDir("test/runtimes/browsers/node_modules");
await emptyDir("test/runtimes/bun/node_modules");
// clean up node_modules
await removeNodeModules();

const denoPkg = JSON.parse(await Deno.readTextFile("./deno.json"));

Expand Down
6 changes: 4 additions & 2 deletions packages/dhkem-secp256k1/dnt.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { build, emptyDir } from "@deno/dnt";
import { copySync } from "@std/fs";
import { removeNodeModules } from "../../utils/misc.ts";

// clean up dist
await emptyDir("../../npm/packages/dhkem-secp256k1");
await emptyDir("../../npm/samples/dhkem-secp256k1");
await emptyDir("../../npm/test/dhkem-secp256k1/runtimes/cloudflare");

await emptyDir("test/runtimes/browsers/node_modules");
await emptyDir("test/runtimes/bun/node_modules");
// clean up node_modules
await removeNodeModules();

const denoPkg = JSON.parse(await Deno.readTextFile("./deno.json"));

Expand Down
6 changes: 4 additions & 2 deletions packages/dhkem-x25519/dnt.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { build, emptyDir } from "jsr:@deno/dnt";
import { copySync } from "@std/fs";
import { removeNodeModules } from "../../utils/misc.ts";

// clean up dist
await emptyDir("../../npm/packages/dhkem-x25519");
await emptyDir("../../npm/samples/dhkem-x25519");
await emptyDir("../../npm/test/dhkem-x25519/runtimes/cloudflare");

await emptyDir("test/runtimes/browsers/node_modules");
await emptyDir("test/runtimes/bun/node_modules");
// clean up node_modules
await removeNodeModules();

const denoPkg = JSON.parse(await Deno.readTextFile("./deno.json"));

Expand Down
6 changes: 4 additions & 2 deletions packages/dhkem-x448/dnt.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { build, emptyDir } from "@deno/dnt";
import { copySync } from "@std/fs";
import { removeNodeModules } from "../../utils/misc.ts";

// clean up dist
await emptyDir("../../npm/packages/dhkem-x448");
await emptyDir("../../npm/samples/dhkem-x448");
await emptyDir("../../npm/test/dhkem-x448/runtimes/cloudflare");

await emptyDir("test/runtimes/browsers/node_modules");
await emptyDir("test/runtimes/bun/node_modules");
// clean up node_modules
await removeNodeModules();

const denoPkg = JSON.parse(await Deno.readTextFile("./deno.json"));

Expand Down
6 changes: 4 additions & 2 deletions packages/hpke-js/dnt.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { build, emptyDir } from "@deno/dnt";
import { copySync } from "@std/fs";
import { removeNodeModules } from "../../utils/misc.ts";

// clean up dist
await emptyDir("../../npm/packages/hpke-js");
await emptyDir("../../npm/samples/hpke-js");
await emptyDir("../../npm/test/hpke-js/runtimes/cloudflare");

await emptyDir("test/runtimes/browsers/node_modules");
await emptyDir("test/runtimes/bun/node_modules");
// clean up node_modules
await removeNodeModules();

const denoPkg = JSON.parse(await Deno.readTextFile("./deno.json"));

Expand Down
6 changes: 4 additions & 2 deletions packages/hybridkem-x-wing/dnt.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { build, emptyDir } from "@deno/dnt";
import { copySync } from "@std/fs";
import { removeNodeModules } from "../../utils/misc.ts";

// clean up dist
await emptyDir("../../npm/packages/hybridkem-x-wing");
await emptyDir("../../npm/samples/hybridkem-x-wing");
await emptyDir("../../npm/test/hybridkem-x-wing/runtimes/cloudflare");

await emptyDir("test/runtimes/browsers/node_modules");
await emptyDir("test/runtimes/bun/node_modules");
// clean up node_modules
await removeNodeModules();

const denoPkg = JSON.parse(await Deno.readTextFile("./deno.json"));

Expand Down
6 changes: 4 additions & 2 deletions packages/hybridkem-x25519-kyber768/dnt.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { build, emptyDir } from "@deno/dnt";
import { copySync } from "@std/fs";
import { removeNodeModules } from "../../utils/misc.ts";

// clean up dist
await emptyDir("../../npm/packages/hybridkem-x25519-kyber768");
await emptyDir("../../npm/samples/hybridkem-x25519-kyber768");
await emptyDir("../../npm/test/hybridkem-x25519-kyber768/runtimes/cloudflare");

await emptyDir("test/runtimes/browsers/node_modules");
await emptyDir("test/runtimes/bun/node_modules");
// clean up node_modules
await removeNodeModules();

const denoPkg = JSON.parse(await Deno.readTextFile("./deno.json"));

Expand Down
6 changes: 4 additions & 2 deletions packages/ml-kem/dnt.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { build, emptyDir } from "@deno/dnt";
import { copySync } from "@std/fs";
import { removeNodeModules } from "../../utils/misc.ts";

// clean up dist
await emptyDir("../../npm/packages/ml-kem");
await emptyDir("../../npm/samples/ml-kem");
await emptyDir("../../npm/test/ml-kem/runtimes/cloudflare");

await emptyDir("test/runtimes/browsers/node_modules");
await emptyDir("test/runtimes/bun/node_modules");
// clean up node_modules
await removeNodeModules();

const denoPkg = JSON.parse(await Deno.readTextFile("./deno.json"));

Expand Down
24 changes: 24 additions & 0 deletions utils/misc.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
export async function removeNodeModules() {
try {
await Deno.remove("test/runtimes/browsers/node_modules", {
recursive: true,
});
} catch {
// ignore
}
try {
await Deno.remove("test/runtimes/bun/node_modules", {
recursive: true,
});
} catch {
// ignore
}
try {
await Deno.remove("test/runtimes/cloudflare/node_modules", {
recursive: true,
});
} catch {
// ignore
}
return;
}

0 comments on commit afb9808

Please sign in to comment.