Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/artifacts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,22 +58,21 @@ export function inventoryArtifacts(
} catch {
continue; // unreadable — skip, don't crash
}
const text = decodeLossy(raw);
if (!matched) {
// Never drop: a file without a rule is still inventoried. Extensionless shebang files are
// scripts; everything else decodable is `unknown`; undecodable bytes are hash-only.
const probe = decodeLossy(raw);
if (path.extname(base) === "" && raw.subarray(0, 2).toString("utf-8") === "#!") {
format = "text";
roles = ["script"];
} else if (probe === undefined) {
} else if (text === undefined) {
format = "binary";
roles = ["unknown"];
} else {
format = "text";
roles = ["unknown"];
}
}
const text = decodeLossy(raw);
const capture = opts.artifactText ?? true;
const cap = opts.artifactTextMaxBytes ?? DEFAULT_ARTIFACT_TEXT_MAX_BYTES;
const textByteLength = text === undefined ? 0 : Buffer.byteLength(text, "utf8");
Expand Down