mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-21 05:50:55 +08:00
* feat: ship the self-hosted native scriptc CLI - Run the shared compiler and CLI natively, including library builds and compile-time evaluation. - Install native platform packages and ship relocatable standalone distributions. - Preserve program semantics and reuse validated build artifacts for fast rebuilds. * fix: complete native CLI integration and validation - Preserve library diagnostics and run recursive compiler work on the main stack. - Restore packaged helper permissions and exercise native npm and Wasm library builds. - Recover interrupted Sandbox status probes within the original command deadline.
27 lines
1.1 KiB
TypeScript
27 lines
1.1 KiB
TypeScript
import { appendFileSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
import { tmpdir } from "node:os";
|
|
import { join } from "node:path";
|
|
|
|
const directory = mkdtempSync(join(tmpdir(), "scriptc-write-union-"));
|
|
const path = join(directory, "data");
|
|
function write(value: string | Uint8Array): void { writeFileSync(path, value); }
|
|
function append(value: string | Uint8Array): void { appendFileSync(path, value); }
|
|
let order = "";
|
|
function destination(): string { order += "path "; return path; }
|
|
function data(bytes: boolean): string | Uint8Array {
|
|
order += "data ";
|
|
return bytes ? Buffer.from([0, 128, 255]) : "é";
|
|
}
|
|
try {
|
|
for (const value of ["text", new Uint8Array([0, 128, 255]), Buffer.from("é"), "", new Uint8Array(0)]) {
|
|
write(value);
|
|
append("!");
|
|
append(Buffer.from([0, 255]));
|
|
console.log(readFileSync(path).toString("hex"));
|
|
}
|
|
writeFileSync(destination(), data(true));
|
|
appendFileSync(destination(), data(false));
|
|
console.log(order);
|
|
console.log(readFileSync(path).toString("hex"));
|
|
} finally { rmSync(directory, { recursive: true, force: true }); }
|