feat(config): add PI_PACKAGE_DIR env var to override package path (#1153)
This commit is contained in:
@@ -31,6 +31,14 @@ export const isBunRuntime = !!process.versions.bun;
|
|||||||
* - For tsx (src/): returns parent directory (the package root)
|
* - For tsx (src/): returns parent directory (the package root)
|
||||||
*/
|
*/
|
||||||
export function getPackageDir(): string {
|
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) {
|
if (isBunBinary) {
|
||||||
// Bun binary: process.execPath points to the compiled executable
|
// Bun binary: process.execPath points to the compiled executable
|
||||||
return dirname(process.execPath);
|
return dirname(process.execPath);
|
||||||
|
|||||||
Reference in New Issue
Block a user