From fdf1e2a41d079c4f2d1f3df7c297fa0d92a18cc9 Mon Sep 17 00:00:00 2001
From: Jacky Zhao <j.zhao2k19@gmail.com>
Date: Thu, 03 Aug 2023 06:29:28 +0000
Subject: [PATCH] use checkout for pulling updates
---
quartz/build.ts | 18 ++++++++----------
1 files changed, 8 insertions(+), 10 deletions(-)
diff --git a/quartz/build.ts b/quartz/build.ts
index b96c462..c8b5b02 100644
--- a/quartz/build.ts
+++ b/quartz/build.ts
@@ -2,7 +2,7 @@
import path from "path"
import { PerfTimer } from "./perf"
import { rimraf } from "rimraf"
-import { globby, isGitIgnored } from "globby"
+import { isGitIgnored } from "globby"
import chalk from "chalk"
import http from "http"
import serveHandler from "serve-handler"
@@ -10,11 +10,12 @@
import { filterContent } from "./processors/filter"
import { emitContent } from "./processors/emit"
import cfg from "../quartz.config"
-import { FilePath, slugifyFilePath } from "./path"
+import { FilePath, joinSegments, slugifyFilePath } from "./path"
import chokidar from "chokidar"
import { ProcessedContent } from "./plugins/vfile"
import WebSocket, { WebSocketServer } from "ws"
import { Argv, BuildCtx } from "./ctx"
+import { glob, toPosixPath } from "./glob"
async function buildQuartz(argv: Argv, version: string) {
const ctx: BuildCtx = {
@@ -42,16 +43,12 @@
console.log(`Cleaned output directory \`${output}\` in ${perf.timeSince("clean")}`)
perf.addEvent("glob")
- const fps = await globby("**/*.md", {
- cwd: argv.directory,
- ignore: cfg.configuration.ignorePatterns,
- gitignore: true,
- })
+ const fps = await glob("**/*.md", argv.directory, cfg.configuration.ignorePatterns)
console.log(
`Found ${fps.length} input files from \`${argv.directory}\` in ${perf.timeSince("glob")}`,
)
- const filePaths = fps.map((fp) => `${argv.directory}${path.sep}${fp}` as FilePath)
+ const filePaths = fps.map((fp) => joinSegments(argv.directory, fp) as FilePath)
ctx.allSlugs = fps.map((fp) => slugifyFilePath(fp as FilePath))
const parsedFiles = await parseMarkdown(ctx, filePaths)
@@ -81,8 +78,9 @@
let toRebuild: Set<FilePath> = new Set()
let toRemove: Set<FilePath> = new Set()
async function rebuild(fp: string, action: "add" | "change" | "delete") {
+ fp = toPosixPath(fp)
if (!ignored(fp)) {
- const filePath = `${argv.directory}${path.sep}${fp}` as FilePath
+ const filePath = joinSegments(argv.directory, fp) as FilePath
if (action === "add" || action === "change") {
toRebuild.add(filePath)
} else if (action === "delete") {
@@ -101,7 +99,7 @@
ctx.allSlugs = [...new Set([...contentMap.keys(), ...toRebuild])]
.filter((fp) => !toRemove.has(fp))
- .map((fp) => slugifyFilePath(path.relative(argv.directory, fp) as FilePath))
+ .map((fp) => slugifyFilePath(path.posix.relative(argv.directory, fp) as FilePath))
const parsedContent = await parseMarkdown(ctx, filesToRebuild)
for (const content of parsedContent) {
--
Gitblit v1.10.0