Skip to content

Commit

Permalink
fix remaining tests
Browse files Browse the repository at this point in the history
  • Loading branch information
benmccann committed Aug 16, 2024
1 parent cae19f7 commit 564aff3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions packages/mdsvex/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export * from './types';

import { join } from 'path';
import fs from 'fs';
import { fileURLToPath } from 'url';
import { parse } from 'svelte/compiler';
import unified from 'unified';
import markdown from 'remark-parse';
Expand Down Expand Up @@ -128,11 +129,11 @@ function to_posix(_path: string): string {

function resolve_layout(layout_path: string): string {
try {
return to_posix(require.resolve(layout_path));
return to_posix(fileURLToPath(import.meta.resolve(layout_path)));
} catch (e) {
try {
const _path = join(process.cwd(), layout_path);
return to_posix(require.resolve(_path));
return to_posix(fileURLToPath(import.meta.resolve(_path)));
} catch (e) {
throw new Error(
`The layout path you provided couldn't be found at either ${layout_path} or ${join(
Expand Down
6 changes: 3 additions & 3 deletions packages/mdsvex/test/it/code_highlighting.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ highlight(
code: string,
lang: string | undefined
): Promise<string> {
// const shiki = require('shiki');
// const shiki = await import('shiki');
const highlighter = await shiki.getHighlighter({
theme: 'material-theme-palenight',
});
Expand Down Expand Up @@ -347,8 +347,8 @@ highlight(
highlight(
'Should be possible to add additional highlighting grammars',
async () => {
require('prismjs');
require('prism-svelte');
await import('prismjs');
await import('prism-svelte');
const output = await mdsvex({
highlight: { alias: { beeboo: 'html' } },
}).markup({
Expand Down

0 comments on commit 564aff3

Please sign in to comment.