mirror of
https://github.com/jackyzha0/quartz.git
synced 2025-12-27 14:54:05 -06:00
chore: use gitIgnore function filter
Signed-off-by: Aaron Pham <contact@aarnphm.xyz>
This commit is contained in:
parent
c7e59c6451
commit
51111af049
@ -19,7 +19,6 @@ import { options } from "./util/sourcemap"
|
||||
import { Mutex } from "async-mutex"
|
||||
import DepGraph from "./depgraph"
|
||||
import { getStaticResourcesFromPlugins } from "./plugins"
|
||||
import loadIgnorePatterns from "./util/loadIgnorePatterns"
|
||||
|
||||
type Dependencies = Record<string, DepGraph<FilePath> | null>
|
||||
|
||||
@ -70,11 +69,9 @@ async function buildQuartz(argv: Argv, mut: Mutex, clientRefresh: () => void) {
|
||||
console.log(`Cleaned output directory \`${output}\` in ${perf.timeSince("clean")}`)
|
||||
|
||||
perf.addEvent("glob")
|
||||
const allFiles = await glob("**/*.*", argv.directory, [
|
||||
...cfg.configuration.ignorePatterns,
|
||||
...loadIgnorePatterns(),
|
||||
])
|
||||
const fps = allFiles.filter((fp) => fp.endsWith(".md")).sort()
|
||||
const gitIgnoreFilter = await isGitIgnored()
|
||||
const allFiles = await glob("**/*.*", argv.directory, [...cfg.configuration.ignorePatterns])
|
||||
const fps = allFiles.filter((fp) => !gitIgnoreFilter(fp) && fp.endsWith(".md")).sort()
|
||||
console.log(
|
||||
`Found ${fps.length} input files from \`${argv.directory}\` in ${perf.timeSince("glob")}`,
|
||||
)
|
||||
|
||||
@ -1,17 +0,0 @@
|
||||
import * as fs from "fs"
|
||||
import * as path from "path"
|
||||
|
||||
function loadIgnorePatterns(): string[] {
|
||||
const gitignorePath = path.join(process.cwd(), ".gitignore")
|
||||
if (!fs.existsSync(gitignorePath)) {
|
||||
return []
|
||||
}
|
||||
|
||||
const gitignoreContent = fs.readFileSync(gitignorePath, "utf-8")
|
||||
return gitignoreContent
|
||||
.split("\n")
|
||||
.map((line) => line.trim())
|
||||
.filter((line) => line !== "" && !line.startsWith("#"))
|
||||
}
|
||||
|
||||
export default loadIgnorePatterns
|
||||
Loading…
Reference in New Issue
Block a user