fix: try using pathe for cwd

This commit is contained in:
Ayo Ayco 2024-12-31 02:25:17 +01:00
parent 2638b28533
commit d446b582dd
3 changed files with 8 additions and 1 deletions

View file

@ -3,6 +3,7 @@ import { consola } from 'consola'
import { parseScript } from 'esprima'
import { loadConfig } from 'c12'
import { eventHandler } from 'h3'
import { resolve } from 'pathe'
/**
* @typedef {import('../config').McFlyConfig} Config
@ -23,10 +24,11 @@ import { eventHandler } from 'h3'
export function useMcFlyRoute({ storage }) {
return eventHandler(async (event) => {
const { path } = event
const rootDir = resolve('.')
const loadedConfig = await loadConfig({
name: 'mcfly',
configFile: 'mcfly.config',
cwd: '.',
cwd: rootDir,
})
const config = {
components: 'js', // work around for c12.loadConfig not working on Netlify function
@ -36,6 +38,7 @@ export function useMcFlyRoute({ storage }) {
let html = await getHtml(path, storage)
consola.info('[INFO]: Config found\n', config)
consola.info('>>> Current Working Directory: ', rootDir)
if (html) {
const transforms = [evaluateServerScript, deleteServerScripts]

View file

@ -27,6 +27,7 @@
"esprima": "^4.0.1",
"h3": "^1.8.2",
"nitropack": "~2.10.4",
"pathe": "^1.1.2",
"ultrahtml": "^1.5.2"
},
"devDependencies": {

View file

@ -100,6 +100,9 @@ importers:
nitropack:
specifier: ~2.10.4
version: 2.10.4(typescript@5.7.2)
pathe:
specifier: ^1.1.2
version: 1.1.2
ultrahtml:
specifier: ^1.5.2
version: 1.5.3