feat: rewrite of publish to go back to js from binaries (#3)

This commit is contained in:
Charles Packer
2025-10-24 22:28:29 -07:00
committed by GitHub
parent 0e4ad63321
commit e356bdce0a
11 changed files with 145 additions and 122 deletions

37
src/utils/fs.ts Normal file
View File

@@ -0,0 +1,37 @@
/**
* File system utilities using Node.js APIs
* Compatible with both Node.js and Bun
*/
import {
existsSync,
readFileSync as fsReadFileSync,
writeFileSync as fsWriteFileSync,
mkdirSync,
} from "node:fs";
import { dirname } from "node:path";
/**
* Read a file and return its contents as text
*/
export async function readFile(path: string): Promise<string> {
return fsReadFileSync(path, { encoding: "utf-8" });
}
/**
* Write content to a file, creating parent directories if needed
*/
export async function writeFile(path: string, content: string): Promise<void> {
const dir = dirname(path);
if (!existsSync(dir)) {
mkdirSync(dir, { recursive: true });
}
fsWriteFileSync(path, content, { encoding: "utf-8", flush: true });
}
/**
* Check if a file exists
*/
export function exists(path: string): boolean {
return existsSync(path);
}