Files
oh-my-pi/packages/natives/scripts/embed-native.ts
T
can1357 89e6479661 refactor: migrated environment variable access from process.env to Bun.env across 71 files
- Migrated all environment variable access from Node.js `process.env` to Bun runtime `Bun.env` API across the entire codebase.
- Updated 71 files including source code, tests, documentation, and configuration to use Bun's native environment variable API.
- Added comprehensive environment variables documentation in `packages/coding-agent/docs/environment-variables.md` covering 100+ environment variables organized by category.
- Updated CHANGELOG entries to reflect migration from `process.env` to `Bun.env` and environment variable prefix changes (PI_* vs OMP_*).
- Maintained identical behavior and logic across all changes - only the environment variable access method was updated.
2026-02-05 04:51:18 +01:00

25 lines
1.2 KiB
TypeScript

import * as path from "node:path";
const reset = process.argv.includes("--reset");
const outputPath = path.join(import.meta.dir, "../src/embedded-addon.ts");
const packageJsonPath = path.join(import.meta.dir, "../package.json");
const stubContent = "export interface EmbeddedAddon {\n\tplatform: string;\n\tversion: string;\n\tfilePath: string;\n}\n\nexport const embeddedAddon: EmbeddedAddon | null = null;\n";
if (reset) {
await Bun.write(outputPath, stubContent);
process.exit(0);
}
const targetPlatform = Bun.env.TARGET_PLATFORM || process.platform;
const targetArch = Bun.env.TARGET_ARCH || process.arch;
const platformTag = `${targetPlatform}-${targetArch}`;
const addonFilename = `pi_natives.${platformTag}.node`;
const packageJson = (await Bun.file(packageJsonPath).json()) as { version: string };
const content = `import addonPath from ${JSON.stringify("../native/" + addonFilename)} with { type: \"file\" };\n\nexport interface EmbeddedAddon {\n\tplatform: string;\n\tversion: string;\n\tfilePath: string;\n}\n\nexport const embeddedAddon: EmbeddedAddon | null = {\n\tplatform: ${JSON.stringify(platformTag)},\n\tversion: ${JSON.stringify(packageJson.version)},\n\tfilePath: addonPath,\n};\n`;
await Bun.write(outputPath, content);