feat(dx/desktop): isolate node_modules dependency

This commit is contained in:
Elian Doran
2025-09-02 10:45:42 +03:00
parent 793102f3ad
commit ae74f8ea83
6 changed files with 103 additions and 5 deletions

20
scripts/utils.mts Normal file
View File

@@ -0,0 +1,20 @@
import { readFileSync } from "fs";
import { platform } from "os";
export function isNixOS() {
if (platform() !== "linux") return false;
const osReleaseFile = readFileSync("/etc/os-release", "utf-8");
return osReleaseFile.includes("ID=nixos");
}
export function resetPath() {
// On Unix-like systems, PATH is usually inherited from login shell
// but npm prepends node_modules/.bin. Let's remove it:
const origPath = process.env.PATH || "";
// npm usually adds something like ".../node_modules/.bin"
process.env.PATH = origPath
.split(":")
.filter(p => !p.includes("node_modules/.bin"))
.join(":");
}