Merge branch 'respect-gitignore'
This commit is contained in:
commit
59246fb460
|
|
@ -12,8 +12,26 @@ import type { TestResult } from "../format.ts"
|
||||||
import { parseDuration } from "../duration.ts"
|
import { parseDuration } from "../duration.ts"
|
||||||
import { rewriteFile } from "../update.ts"
|
import { rewriteFile } from "../update.ts"
|
||||||
|
|
||||||
|
async function filterGitignored(files: string[]): Promise<string[]> {
|
||||||
|
if (files.length === 0) return files
|
||||||
|
try {
|
||||||
|
const proc = Bun.spawn(["git", "check-ignore", "--stdin"], {
|
||||||
|
stdin: new Blob([files.join("\n")]),
|
||||||
|
stdout: "pipe",
|
||||||
|
stderr: "ignore",
|
||||||
|
})
|
||||||
|
const output = await new Response(proc.stdout).text()
|
||||||
|
await proc.exited
|
||||||
|
const ignored = new Set(output.trim().split("\n").filter(Boolean))
|
||||||
|
return files.filter(f => !ignored.has(f))
|
||||||
|
} catch {
|
||||||
|
return files
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function findShoutFiles(paths: string[]): Promise<string[]> {
|
async function findShoutFiles(paths: string[]): Promise<string[]> {
|
||||||
const files: string[] = []
|
const explicit: string[] = []
|
||||||
|
const discovered: string[] = []
|
||||||
|
|
||||||
for (const p of paths) {
|
for (const p of paths) {
|
||||||
const abs = resolve(p)
|
const abs = resolve(p)
|
||||||
|
|
@ -22,7 +40,7 @@ async function findShoutFiles(paths: string[]): Promise<string[]> {
|
||||||
: null
|
: null
|
||||||
|
|
||||||
if (stat && abs.endsWith(".shout")) {
|
if (stat && abs.endsWith(".shout")) {
|
||||||
files.push(abs)
|
explicit.push(abs)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -31,16 +49,17 @@ async function findShoutFiles(paths: string[]): Promise<string[]> {
|
||||||
const entries = await readdir(abs, { recursive: true })
|
const entries = await readdir(abs, { recursive: true })
|
||||||
for (const entry of entries) {
|
for (const entry of entries) {
|
||||||
if (entry.endsWith(".shout")) {
|
if (entry.endsWith(".shout")) {
|
||||||
files.push(resolve(abs, entry))
|
discovered.push(resolve(abs, entry))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
// If not a directory, try as file anyway
|
// If not a directory, try as file anyway
|
||||||
if (abs.endsWith(".shout")) files.push(abs)
|
if (abs.endsWith(".shout")) explicit.push(abs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return files.sort()
|
const filtered = await filterGitignored(discovered)
|
||||||
|
return [...explicit, ...filtered].sort()
|
||||||
}
|
}
|
||||||
|
|
||||||
import pkg from "../../package.json"
|
import pkg from "../../package.json"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user