@runeya/runeya 2.0.136 → 2.0.138

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
+ promoteOnPath(dirname(process.execPath), environment);
4909
4909
  }
4910
4910
  function appendToPath(dir, environment = process.env) {
4911
4911
  if (!dir) return;
@@ -4914,6 +4914,12 @@ 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 promoteOnPath(dir, environment = process.env) {
4918
+ if (!dir) return;
4919
+ const current = environment["PATH"] ?? "";
4920
+ const others = current.split(delimiter).filter(Boolean).filter((entry) => entry !== dir);
4921
+ environment["PATH"] = [dir, ...others].join(delimiter);
4922
+ }
4917
4923
 
4918
4924
  // ../../packages/shared/src/node/user-path.ts
4919
4925
  import { execFile as execFile3 } from "child_process";
@@ -4938,7 +4944,10 @@ function commonUserBins(home) {
4938
4944
  async function readLoginShellPath() {
4939
4945
  if (process.platform === "win32") return null;
4940
4946
  const shell = process.env["SHELL"];
4941
- if (!shell || !existsSync(shell)) return null;
4947
+ if (!shell || !existsSync(shell)) {
4948
+ warnProbeFailed(shell ? `shell introuvable : ${shell}` : "SHELL absent de cet environnement");
4949
+ return null;
4950
+ }
4942
4951
  try {
4943
4952
  const { stdout } = await execFileAsync(shell, ["-l", "-i", "-c", `echo "${MARKER}$PATH"`], {
4944
4953
  timeout: SHELL_TIMEOUT_MS,
@@ -4948,18 +4957,31 @@ async function readLoginShellPath() {
4948
4957
  env: { ...process.env, TERM: "dumb" }
4949
4958
  });
4950
4959
  const line = stdout.split("\n").find((l) => l.includes(MARKER));
4951
- if (!line) return null;
4960
+ if (!line) {
4961
+ warnProbeFailed(`aucune ligne marqu\xE9e dans la r\xE9ponse de ${shell}`);
4962
+ return null;
4963
+ }
4952
4964
  const value = line.slice(line.indexOf(MARKER) + MARKER.length).trim();
4953
- return value.length > 0 ? value : null;
4954
- } catch {
4965
+ if (value.length === 0) {
4966
+ warnProbeFailed(`${shell} a r\xE9pondu un PATH vide`);
4967
+ return null;
4968
+ }
4969
+ return value;
4970
+ } catch (err) {
4971
+ const reason = err.killed ? `${shell} n'a pas r\xE9pondu en ${SHELL_TIMEOUT_MS} ms` : `${shell} a \xE9chou\xE9 : ${err instanceof Error ? err.message : String(err)}`;
4972
+ warnProbeFailed(reason);
4955
4973
  return null;
4956
4974
  }
4957
4975
  }
4976
+ function warnProbeFailed(reason) {
4977
+ console.warn(`[path] PATH du shell de connexion non lu (${reason}) \u2014 les outils install\xE9s par l'utilisateur peuvent rester introuvables.`);
4978
+ }
4958
4979
  async function ensureUserBinsOnPath(environment = process.env, home = homedir6()) {
4959
4980
  const shellPath = await readLoginShellPath();
4960
4981
  if (shellPath) {
4961
- for (const entry of shellPath.split(delimiter2).filter(Boolean)) {
4962
- appendToPath(entry, environment);
4982
+ const entries = shellPath.split(delimiter2).filter(Boolean);
4983
+ for (let i = entries.length - 1; i >= 0; i--) {
4984
+ promoteOnPath(entries[i], environment);
4963
4985
  }
4964
4986
  }
4965
4987
  for (const dir of commonUserBins(home)) {