From 7941b0d87a8378a3f933ca079f1abe6934e69ca9 Mon Sep 17 00:00:00 2001 From: Jacky Zhao Date: Wed, 2 Aug 2023 23:04:26 -0700 Subject: [PATCH] use posix style paths for all path ops --- quartz/bootstrap-cli.mjs | 6 ------ quartz/build.ts | 2 +- quartz/plugins/emitters/aliases.ts | 2 +- quartz/plugins/emitters/static.ts | 3 +-- quartz/plugins/transformers/lastmod.ts | 2 +- quartz/plugins/transformers/links.ts | 2 +- quartz/processors/parse.ts | 2 +- 7 files changed, 6 insertions(+), 13 deletions(-) diff --git a/quartz/bootstrap-cli.mjs b/quartz/bootstrap-cli.mjs index 0fbc6960..21449f5b 100755 --- a/quartz/bootstrap-cli.mjs +++ b/quartz/bootstrap-cli.mjs @@ -49,12 +49,6 @@ const SyncArgv = { default: true, describe: "push updates to your Quartz fork", }, - force: { - boolean: true, - alias: ["f"], - default: true, - describe: "whether to apply the --force flag to git commands", - }, pull: { boolean: true, default: true, diff --git a/quartz/build.ts b/quartz/build.ts index 07b51fb1..c8b5b02d 100644 --- a/quartz/build.ts +++ b/quartz/build.ts @@ -99,7 +99,7 @@ async function startServing(ctx: BuildCtx, initialContent: ProcessedContent[]) { 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) { diff --git a/quartz/plugins/emitters/aliases.ts b/quartz/plugins/emitters/aliases.ts index 7d2c08ad..818b1d7d 100644 --- a/quartz/plugins/emitters/aliases.ts +++ b/quartz/plugins/emitters/aliases.ts @@ -18,7 +18,7 @@ export const AliasRedirects: QuartzEmitterPlugin = () => ({ for (const [_tree, file] of content) { const ogSlug = canonicalizeServer(file.data.slug!) - const dir = path.relative(argv.directory, file.dirname ?? argv.directory) + const dir = path.posix.relative(argv.directory, file.dirname ?? argv.directory) let aliases: CanonicalSlug[] = [] if (file.data.frontmatter?.aliases) { diff --git a/quartz/plugins/emitters/static.ts b/quartz/plugins/emitters/static.ts index 043a4619..75bcc746 100644 --- a/quartz/plugins/emitters/static.ts +++ b/quartz/plugins/emitters/static.ts @@ -1,6 +1,5 @@ import { FilePath, QUARTZ, joinSegments } from "../../path" import { QuartzEmitterPlugin } from "../types" -import path from "path" import fs from "fs" import { glob } from "../../glob" @@ -10,7 +9,7 @@ export const Static: QuartzEmitterPlugin = () => ({ return [] }, async emit({ argv, cfg }, _content, _resources, _emit): Promise { - const staticPath = path.join(QUARTZ, "static") + const staticPath = joinSegments(QUARTZ, "static") const fps = await glob("**", staticPath, cfg.configuration.ignorePatterns) await fs.promises.cp(staticPath, joinSegments(argv.output, "static"), { recursive: true }) return fps.map((fp) => joinSegments("static", fp)) as FilePath[] diff --git a/quartz/plugins/transformers/lastmod.ts b/quartz/plugins/transformers/lastmod.ts index ecdcc413..15dd89e3 100644 --- a/quartz/plugins/transformers/lastmod.ts +++ b/quartz/plugins/transformers/lastmod.ts @@ -27,7 +27,7 @@ export const CreatedModifiedDate: QuartzTransformerPlugin | und let modified: MaybeDate = undefined let published: MaybeDate = undefined - const fp = path.join(file.cwd, file.data.filePath as string) + const fp = path.posix.join(file.cwd, file.data.filePath as string) for (const source of opts.priority) { if (source === "filesystem") { const st = await fs.promises.stat(fp) diff --git a/quartz/plugins/transformers/links.ts b/quartz/plugins/transformers/links.ts index aecb58f8..07650621 100644 --- a/quartz/plugins/transformers/links.ts +++ b/quartz/plugins/transformers/links.ts @@ -76,7 +76,7 @@ export const CrawlLinks: QuartzTransformerPlugin | undefined> = // don't process external links or intra-document anchors if (!(isAbsoluteUrl(dest) || dest.startsWith("#"))) { dest = node.properties.href = transformLink(dest) - const canonicalDest = path.normalize(joinSegments(curSlug, dest)) + const canonicalDest = path.posix.normalize(joinSegments(curSlug, dest)) const [destCanonical, _destAnchor] = splitAnchor(canonicalDest) outgoing.add(destCanonical as CanonicalSlug) } diff --git a/quartz/processors/parse.ts b/quartz/processors/parse.ts index 23af762a..289ca946 100644 --- a/quartz/processors/parse.ts +++ b/quartz/processors/parse.ts @@ -91,7 +91,7 @@ export function createFileParser(ctx: BuildCtx, fps: FilePath[]) { } // base data properties that plugins may use - file.data.slug = slugifyFilePath(path.relative(argv.directory, file.path) as FilePath) + file.data.slug = slugifyFilePath(path.posix.relative(argv.directory, file.path) as FilePath) file.data.filePath = fp const ast = processor.parse(file)