[Init] Initial commit - NetMesh terminal manager
Some checks failed
build-packages / resolve bundled mosh-client (push) Has been cancelled
build-packages / resolve bundled et-client (push) Has been cancelled
build-packages / build-macos (push) Has been cancelled
build-packages / build-windows (push) Has been cancelled
build-packages / build-linux-x64 (push) Has been cancelled
build-packages / build-linux-arm64 (push) Has been cancelled
build-packages / release (push) Has been cancelled
build-packages / update Nix release metadata (push) Has been cancelled
build-packages / bump homebrew tap (push) Has been cancelled
test / lint-and-test (push) Has been cancelled
AI automation / Route event (push) Has been cancelled
AI automation / Hand reopened issue to maintainers (push) Has been cancelled
AI automation / Clean source issue state (push) Has been cancelled
AI automation / Reconcile handoffs (push) Has been cancelled
AI automation / Classify issue (push) Has been cancelled
AI automation / Claude Code smoke (push) Has been cancelled
AI automation / Review issue follow-up (push) Has been cancelled
AI automation / Publish issue follow-up (push) Has been cancelled
AI automation / Implement with Claude Code (push) Has been cancelled
AI automation / Publish implement PR (push) Has been cancelled
AI automation / Continue queued issue comments (push) Has been cancelled
AI automation / Codex review loop (push) Has been cancelled
AI automation / Publish Codex fix (push) Has been cancelled
AI automation / Clear Codex dispatch marker (push) Has been cancelled
AI automation / Own PR re-request Codex (push) Has been cancelled
AI automation / External PR re-request Codex (push) Has been cancelled
AI automation / Poll Codex reaction / retry (push) Has been cancelled
build-et-binaries / build-linux-x64 (push) Has been cancelled
build-et-binaries / build-linux-arm64 (push) Has been cancelled
build-et-binaries / build-macos-universal (push) Has been cancelled
build-et-binaries / build-windows-x64 (push) Has been cancelled
build-et-binaries / release (push) Has been cancelled
Some checks failed
build-packages / resolve bundled mosh-client (push) Has been cancelled
build-packages / resolve bundled et-client (push) Has been cancelled
build-packages / build-macos (push) Has been cancelled
build-packages / build-windows (push) Has been cancelled
build-packages / build-linux-x64 (push) Has been cancelled
build-packages / build-linux-arm64 (push) Has been cancelled
build-packages / release (push) Has been cancelled
build-packages / update Nix release metadata (push) Has been cancelled
build-packages / bump homebrew tap (push) Has been cancelled
test / lint-and-test (push) Has been cancelled
AI automation / Route event (push) Has been cancelled
AI automation / Hand reopened issue to maintainers (push) Has been cancelled
AI automation / Clean source issue state (push) Has been cancelled
AI automation / Reconcile handoffs (push) Has been cancelled
AI automation / Classify issue (push) Has been cancelled
AI automation / Claude Code smoke (push) Has been cancelled
AI automation / Review issue follow-up (push) Has been cancelled
AI automation / Publish issue follow-up (push) Has been cancelled
AI automation / Implement with Claude Code (push) Has been cancelled
AI automation / Publish implement PR (push) Has been cancelled
AI automation / Continue queued issue comments (push) Has been cancelled
AI automation / Codex review loop (push) Has been cancelled
AI automation / Publish Codex fix (push) Has been cancelled
AI automation / Clear Codex dispatch marker (push) Has been cancelled
AI automation / Own PR re-request Codex (push) Has been cancelled
AI automation / External PR re-request Codex (push) Has been cancelled
AI automation / Poll Codex reaction / retry (push) Has been cancelled
build-et-binaries / build-linux-x64 (push) Has been cancelled
build-et-binaries / build-linux-arm64 (push) Has been cancelled
build-et-binaries / build-macos-universal (push) Has been cancelled
build-et-binaries / build-windows-x64 (push) Has been cancelled
build-et-binaries / release (push) Has been cancelled
This commit is contained in:
65
lib/localShell.cjs
Normal file
65
lib/localShell.cjs
Normal file
@@ -0,0 +1,65 @@
|
||||
"use strict";
|
||||
|
||||
const localShellRules = require("./localShellRules.json");
|
||||
|
||||
const POWERSHELL_SHELLS = new Set(localShellRules.powershellShells);
|
||||
const CMD_SHELLS = new Set(localShellRules.cmdShells);
|
||||
const FISH_SHELLS = new Set(localShellRules.fishShells);
|
||||
const POSIX_SHELLS = new Set(localShellRules.posixShells);
|
||||
const WSL_SHELLS = new Set(localShellRules.wslShells);
|
||||
|
||||
function getExecutableBaseName(filePath) {
|
||||
const normalized = String(filePath || "").trim();
|
||||
if (!normalized) return "";
|
||||
const parts = normalized.split(/[\\/]/);
|
||||
return (parts[parts.length - 1] || "").toLowerCase();
|
||||
}
|
||||
|
||||
function detectLocalOs(platformLike) {
|
||||
const platform = String(platformLike || "").toLowerCase();
|
||||
if (platform.includes("mac")) return "macos";
|
||||
if (platform.includes("win")) return "windows";
|
||||
if (platform.includes("darwin")) return "macos";
|
||||
return "linux";
|
||||
}
|
||||
|
||||
/**
|
||||
* True when `filePath` points inside `%LOCALAPPDATA%\Microsoft\WindowsApps`,
|
||||
* i.e. it is a Windows App Execution Alias (MSIX/Store install stub).
|
||||
*
|
||||
* Aliases are zero-byte reparse points: `fs.statSync()` fails with EACCES and
|
||||
* `fs.existsSync()` returns false, yet spawning the alias path still launches
|
||||
* the packaged application. Consumers must not use existence checks to reject
|
||||
* these paths. Deliberately free of `node:path` — this module is also bundled
|
||||
* for the renderer.
|
||||
*/
|
||||
function isWindowsAppExecutionAliasPath(filePath) {
|
||||
if (!filePath || typeof filePath !== "string") return false;
|
||||
// Read via globalThis so renderer bundles (where `process` is not a global)
|
||||
// stay valid; alias detection is a main-process concern and safely
|
||||
// returns false when the env is unavailable.
|
||||
const localAppData = globalThis.process?.env?.LOCALAPPDATA;
|
||||
if (!localAppData) return false;
|
||||
const normalize = (p) => p.replace(/\\/g, "/").replace(/\/+/g, "/").toLowerCase();
|
||||
const aliasDir = `${normalize(localAppData)}/microsoft/windowsapps/`;
|
||||
return normalize(filePath).startsWith(aliasDir);
|
||||
}
|
||||
|
||||
function classifyLocalShellType(shellPath, platformLike) {
|
||||
const shellName = getExecutableBaseName(shellPath);
|
||||
if (POWERSHELL_SHELLS.has(shellName)) return "powershell";
|
||||
if (CMD_SHELLS.has(shellName)) return "cmd";
|
||||
if (FISH_SHELLS.has(shellName)) return "fish";
|
||||
if (POSIX_SHELLS.has(shellName)) return "posix";
|
||||
if (WSL_SHELLS.has(shellName)) return "posix";
|
||||
if (!shellName) {
|
||||
return detectLocalOs(platformLike) === "windows" ? "powershell" : "posix";
|
||||
}
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
classifyLocalShellType,
|
||||
detectLocalOs,
|
||||
isWindowsAppExecutionAliasPath,
|
||||
};
|
||||
Reference in New Issue
Block a user