Skip to content

Commit

Permalink
Fix interpolate on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
nickgal committed Apr 29, 2023
1 parent 0991bcb commit 8bf15eb
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// https://github.com/nuxt/content/pull/676

const path = require('path');
const fs = require('fs/promises');
import path from 'path'
import fs from 'fs/promises'

const interpolateSourceCode = async (file) => {
if (file.extension !== '.md') {
Expand All @@ -26,8 +26,7 @@ const interpolateSourceCode = async (file) => {
if (inCodeBlock && line.startsWith(sourceKey)) {
try {
const [lineIndent, relativePath] = lines[i].split(sourceKey)
// const sourceCode = path.resolve(path.dirname(file.path), relativePath)
const sourceCode = path.resolve(basePath, relativePath)
const sourceCode = path.resolve(basePath, relativePath.trim())
const buffer = await fs.readFile(sourceCode,{encoding: 'utf8'})

let indentedLine = lineIndent + buffer.toString().replace(/\n/g, "\n" + lineIndent)
Expand Down

0 comments on commit 8bf15eb

Please sign in to comment.