Skip to content

Commit

Permalink
Fix path/URI conversion (SO 77980517)
Browse files Browse the repository at this point in the history
  • Loading branch information
CherryDT committed Feb 12, 2024
1 parent 1310501 commit 42f65ae
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/helpers/markdown.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { join } from 'path';
import { normaliseConfig, createCommandLineConfig } from './command-line.helper.js';
import { generateTableFooter, getOptionSections, mapDefinitionDetails } from './options.helper.js';
import { convertChalkStringToMarkdown } from './string.helper.js';
import { pathToFileURL } from 'url';

export function createUsageGuide<T = any>(config: UsageGuideConfig<T>): string {
const options = config.parseOptions || {};
Expand Down Expand Up @@ -167,7 +168,7 @@ export async function generateUsageGuides(args: IWriteMarkDown): Promise<string[
export async function loadArgConfig(jsFile: string, importName: string): Promise<UsageGuideConfig | undefined> {
const jsPath = join(process.cwd(), jsFile);
// eslint-disable-next-line @typescript-eslint/no-var-requires
const jsExports = await import(jsPath);
const jsExports = await import(pathToFileURL(jsPath).href);

const argConfig: UsageGuideConfig = jsExports[importName];

Expand Down
3 changes: 1 addition & 2 deletions src/write-markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@ import { addCommandLineArgsFooter, addContent, generateUsageGuides, insertCode }
import { argumentConfig, parseOptions } from './write-markdown.constants.js';
import format from 'string-format';
import chalk from 'chalk';
import { pathToFileURL } from "url"

async function writeMarkdown() {
const args = parse<IWriteMarkDown>(argumentConfig, parseOptions);

const markdownPath = pathToFileURL(resolve(args.markdownPath)).href;
const markdownPath = resolve(args.markdownPath);

console.log(`Loading existing file from '${chalk.blue(markdownPath)}'`);
const markdownFileContent = readFileSync(markdownPath).toString();
Expand Down

0 comments on commit 42f65ae

Please sign in to comment.