From 2bc8bef5247181922979ff0bccf401a391886456 Mon Sep 17 00:00:00 2001 From: Dave Star Date: Mon, 24 Jan 2022 16:51:05 +0000 Subject: [PATCH] fix __dirname bug in Windows --- compiler/src/knitr/index.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/compiler/src/knitr/index.ts b/compiler/src/knitr/index.ts index 52a0bb25..f102173c 100644 --- a/compiler/src/knitr/index.ts +++ b/compiler/src/knitr/index.ts @@ -1,5 +1,6 @@ import { exec } from 'child_process'; import path from 'path'; +import { fileURLToPath } from 'url'; import chalk from 'chalk'; import hashSum from 'hash-sum'; @@ -9,7 +10,7 @@ import { Context } from '../context'; import { warnMessage } from '../utils/message'; import { mkdir, rmFile, writeFile } from '../utils/utils'; -const __dirname = new URL('.', import.meta.url).pathname; +const __dirname = path.dirname(fileURLToPath(import.meta.url)); export async function knitr(file: VFile, ctx: Context) { const result = await execKnitr(file, ctx);