fix: try using pathe for cwd
This commit is contained in:
parent
2638b28533
commit
d446b582dd
3 changed files with 8 additions and 1 deletions
|
@ -3,6 +3,7 @@ import { consola } from 'consola'
|
||||||
import { parseScript } from 'esprima'
|
import { parseScript } from 'esprima'
|
||||||
import { loadConfig } from 'c12'
|
import { loadConfig } from 'c12'
|
||||||
import { eventHandler } from 'h3'
|
import { eventHandler } from 'h3'
|
||||||
|
import { resolve } from 'pathe'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {import('../config').McFlyConfig} Config
|
* @typedef {import('../config').McFlyConfig} Config
|
||||||
|
@ -23,10 +24,11 @@ import { eventHandler } from 'h3'
|
||||||
export function useMcFlyRoute({ storage }) {
|
export function useMcFlyRoute({ storage }) {
|
||||||
return eventHandler(async (event) => {
|
return eventHandler(async (event) => {
|
||||||
const { path } = event
|
const { path } = event
|
||||||
|
const rootDir = resolve('.')
|
||||||
const loadedConfig = await loadConfig({
|
const loadedConfig = await loadConfig({
|
||||||
name: 'mcfly',
|
name: 'mcfly',
|
||||||
configFile: 'mcfly.config',
|
configFile: 'mcfly.config',
|
||||||
cwd: '.',
|
cwd: rootDir,
|
||||||
})
|
})
|
||||||
const config = {
|
const config = {
|
||||||
components: 'js', // work around for c12.loadConfig not working on Netlify function
|
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)
|
let html = await getHtml(path, storage)
|
||||||
|
|
||||||
consola.info('[INFO]: Config found\n', config)
|
consola.info('[INFO]: Config found\n', config)
|
||||||
|
consola.info('>>> Current Working Directory: ', rootDir)
|
||||||
|
|
||||||
if (html) {
|
if (html) {
|
||||||
const transforms = [evaluateServerScript, deleteServerScripts]
|
const transforms = [evaluateServerScript, deleteServerScripts]
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
"esprima": "^4.0.1",
|
"esprima": "^4.0.1",
|
||||||
"h3": "^1.8.2",
|
"h3": "^1.8.2",
|
||||||
"nitropack": "~2.10.4",
|
"nitropack": "~2.10.4",
|
||||||
|
"pathe": "^1.1.2",
|
||||||
"ultrahtml": "^1.5.2"
|
"ultrahtml": "^1.5.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|
|
@ -100,6 +100,9 @@ importers:
|
||||||
nitropack:
|
nitropack:
|
||||||
specifier: ~2.10.4
|
specifier: ~2.10.4
|
||||||
version: 2.10.4(typescript@5.7.2)
|
version: 2.10.4(typescript@5.7.2)
|
||||||
|
pathe:
|
||||||
|
specifier: ^1.1.2
|
||||||
|
version: 1.1.2
|
||||||
ultrahtml:
|
ultrahtml:
|
||||||
specifier: ^1.5.2
|
specifier: ^1.5.2
|
||||||
version: 1.5.3
|
version: 1.5.3
|
||||||
|
|
Loading…
Reference in a new issue