feat(config): add PI_PACKAGE_DIR env var to override package path (#1153)

This commit is contained in:
George Zhang
2026-02-01 08:52:44 -08:00
committed by GitHub
parent 8306b3bc20
commit 0e49235af0

View File

@@ -31,6 +31,14 @@ export const isBunRuntime = !!process.versions.bun;
* - For tsx (src/): returns parent directory (the package root)
*/
export function getPackageDir(): string {
// Allow override via environment variable (useful for Nix/Guix where store paths tokenize poorly)
const envDir = process.env.PI_PACKAGE_DIR;
if (envDir) {
if (envDir === "~") return homedir();
if (envDir.startsWith("~/")) return homedir() + envDir.slice(1);
return envDir;
}
if (isBunBinary) {
// Bun binary: process.execPath points to the compiled executable
return dirname(process.execPath);