deno/tools/update_node_gyp_for_tests.ts
Divy 56d6a74894
Some checks failed
ci / lint debug macos-x86_64 (push) Has been cancelled
ci / lint debug windows-x86_64 (push) Has been cancelled
ci / test debug linux-x86_64 (push) Has been cancelled
ci / test release linux-x86_64 (push) Has been cancelled
ci / test debug macos-x86_64 (push) Has been cancelled
ci / test release macos-x86_64 (push) Has been cancelled
ci / test debug windows-x86_64 (push) Has been cancelled
ci / test release windows-x86_64 (push) Has been cancelled
ci / build libs (push) Has been cancelled
ci / publish canary (push) Has been cancelled
ci / pre-build (push) Has been cancelled
ci / test debug linux-aarch64 (push) Has been cancelled
ci / test release linux-aarch64 (push) Has been cancelled
ci / test debug macos-aarch64 (push) Has been cancelled
ci / test release macos-aarch64 (push) Has been cancelled
ci / bench release linux-x86_64 (push) Has been cancelled
ci / lint debug linux-x86_64 (push) Has been cancelled
fix: upgrade @node/types to 24 (#30343)
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2025-08-07 16:08:47 +00:00

66 lines
1.6 KiB
TypeScript

#!/usr/bin/env -S deno run -ERNW --allow-sys
// Copyright 2018-2025 the Deno authors. MIT license.
// This script updates `test/testdata/assets/node-gyp/*` files that
// are used by the test registry.
import { create, extract } from "npm:tar";
import { Readable } from "node:stream";
import { join } from "jsr:@std/path";
import { createGzip } from "node:zlib";
import { createWriteStream } from "node:fs";
let version = Deno.args[0];
if (!version) {
throw new Error("expected node version as arg, e.g. v20.11.1");
}
version = version.startsWith("v") ? version : "v" + version;
const response = await fetch(
`https://nodejs.org/dist/${version}/node-${version}-headers.tar.gz`,
);
if (!response.body) {
throw new Error("expected response body");
}
const temp = await Deno.makeTempDir();
const p = Promise.withResolvers<void>();
Readable.fromWeb(response.body).pipe(
extract({
cwd: temp,
}),
).once("close", (_r) => {
p.resolve();
});
await p.promise;
await Deno.remove(join(temp, `node-${version}`, "include", "node", "openssl"), {
recursive: true,
});
const stream = create({
// file: `./node-${version}-headers.tar.gz`,
// sync: true,
onWriteEntry(entry) {
if (entry.path.startsWith(temp.slice(1))) {
entry.path = entry.path.slice(temp.length);
}
},
}, [join(temp, `node-${version}`)]);
const gzip = createGzip();
const fsStream = createWriteStream(
`./tests/testdata/assets/node-gyp/node-${version}-headers.tar.gz`,
);
const p2 = Promise.withResolvers<void>();
stream.pipe(gzip).pipe(fsStream).on("close", (_) => {
p2.resolve();
});
await p2.promise;