fix(artifacts): mark Windows host executables by extension (#1823)
Windows has no POSIX execute bit; Node reports file modes from the read-only attribute alone, so every host file, including PE images, reported `executable: false` while the same occurrence reported `artifact_kind: executable`. Derive the host executable marking once: POSIX permission bits stay authoritative, and Windows marks regular files with the CreateProcess/cmd launchable extensions. Fixes #1819 Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
76e4153d34
commit
91f843bf38
@@ -0,0 +1,22 @@
|
||||
import type { Stats } from "node:fs";
|
||||
import { extname } from "node:path";
|
||||
|
||||
/** Extensions Windows launches directly through CreateProcess or cmd.exe. */
|
||||
const windowsLaunchableExtensions = new Set([".bat", ".cmd", ".com", ".exe"]);
|
||||
|
||||
/**
|
||||
* Whether a host filesystem entry carries the host's executable marking.
|
||||
*
|
||||
* POSIX hosts mark executability with permission bits. Windows has no execute
|
||||
* bit (Node reports file modes from the read-only attribute alone), so it marks
|
||||
* launchable files by extension instead.
|
||||
*/
|
||||
export const hostExecutableMarking = (
|
||||
path: string,
|
||||
metadata: Pick<Stats, "mode" | "isFile">,
|
||||
platform: NodeJS.Platform = process.platform,
|
||||
): boolean =>
|
||||
platform === "win32"
|
||||
? metadata.isFile() &&
|
||||
windowsLaunchableExtensions.has(extname(path).toLowerCase())
|
||||
: (metadata.mode & 0o111) !== 0;
|
||||
Reference in New Issue
Block a user