Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cli): handle windows filepaths when replacing referenced mdx #5842

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { readFile } from "fs/promises";
import path from "path";

import { AbsoluteFilePath, RelativeFilePath, dirname, resolve } from "@fern-api/fs-utils";
import { AbsoluteFilePath, dirname, resolve } from "@fern-api/fs-utils";
import { TaskContext } from "@fern-api/task-context";

async function defaultFileLoader(filepath: AbsoluteFilePath): Promise<string> {
Expand Down Expand Up @@ -45,8 +46,8 @@ export async function replaceReferencedCode({
}

const filepath = resolve(
src.startsWith("/") ? absolutePathToFernFolder : dirname(absolutePathToMarkdownFile),
RelativeFilePath.of(src.replace(/^\//, ""))
path.isAbsolute(src) ? absolutePathToFernFolder : dirname(absolutePathToMarkdownFile),
path.normalize(src)
);

try {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { readFile } from "fs/promises";
import grayMatter from "gray-matter";
import path from "path";

import { AbsoluteFilePath, RelativeFilePath, dirname, resolve } from "@fern-api/fs-utils";
import { AbsoluteFilePath, dirname, resolve } from "@fern-api/fs-utils";
import { TaskContext } from "@fern-api/task-context";

async function defaultMarkdownLoader(filepath: AbsoluteFilePath) {
Expand Down Expand Up @@ -45,8 +46,8 @@ export async function replaceReferencedMarkdown({
}

const filepath = resolve(
src.startsWith("/") ? absolutePathToFernFolder : dirname(absolutePathToMarkdownFile),
RelativeFilePath.of(src.replace(/^\//, ""))
path.isAbsolute(src) ? absolutePathToFernFolder : dirname(absolutePathToMarkdownFile),
path.normalize(src)
);

try {
Expand Down
Loading