@runeya/runeya 2.0.136 → 2.0.137

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/agent/index.js CHANGED
@@ -4905,7 +4905,7 @@ import { networkInterfaces as networkInterfaces2, homedir as homedir7, platform
4905
4905
  // ../../packages/shared/src/node/node-path.ts
4906
4906
  import { dirname, delimiter } from "path";
4907
4907
  function ensureNodeBinOnPath(environment = process.env) {
4908
- appendToPath(dirname(process.execPath), environment);
4908
+ prependToPath(dirname(process.execPath), environment);
4909
4909
  }
4910
4910
  function appendToPath(dir, environment = process.env) {
4911
4911
  if (!dir) return;
@@ -4914,6 +4914,13 @@ function appendToPath(dir, environment = process.env) {
4914
4914
  if (entries.includes(dir)) return;
4915
4915
  environment["PATH"] = entries.length > 0 ? `${current}${delimiter}${dir}` : dir;
4916
4916
  }
4917
+ function prependToPath(dir, environment = process.env) {
4918
+ if (!dir) return;
4919
+ const current = environment["PATH"] ?? "";
4920
+ const entries = current.split(delimiter).filter(Boolean);
4921
+ if (entries.includes(dir)) return;
4922
+ environment["PATH"] = entries.length > 0 ? `${dir}${delimiter}${current}` : dir;
4923
+ }
4917
4924
 
4918
4925
  // ../../packages/shared/src/node/user-path.ts
4919
4926
  import { execFile as execFile3 } from "child_process";
@@ -4958,8 +4965,9 @@ async function readLoginShellPath() {
4958
4965
  async function ensureUserBinsOnPath(environment = process.env, home = homedir6()) {
4959
4966
  const shellPath = await readLoginShellPath();
4960
4967
  if (shellPath) {
4961
- for (const entry of shellPath.split(delimiter2).filter(Boolean)) {
4962
- appendToPath(entry, environment);
4968
+ const entries = shellPath.split(delimiter2).filter(Boolean);
4969
+ for (let i = entries.length - 1; i >= 0; i--) {
4970
+ prependToPath(entries[i], environment);
4963
4971
  }
4964
4972
  }
4965
4973
  for (const dir of commonUserBins(home)) {