Skip to content

Commit

Permalink
load app fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nksaraf committed Dec 28, 2023
1 parent 0160b5c commit 44fa5ca
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions packages/vinxi/lib/load-app.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/// <reference types="bun-types" />
import { loadConfig } from "c12";
import { existsSync } from "fs";
import { fileURLToPath } from "url";
import { joinURL } from "ufo";
import { fileURLToPath, pathToFileURL } from "url";

import { createApp } from "./app.js";
import { log } from "./logger.js";
Expand Down Expand Up @@ -32,21 +33,26 @@ async function loadFile({ ...options }) {

if (options.name) {
if (existsSync(process.cwd() + "/" + options.name + ".config.js")) {
return import(process.cwd() + "/" + options.name + ".config.js").then(
(m) => ({
config: m.default,
}),
);
return import(joinURL(
pathToFileURL(process.cwd()).href,
`${options.name}.config.js`,
),).then((m) => ({
config: m.default,
}));
} else if (existsSync(process.cwd() + "/" + options.name + ".config.mjs")) {
return import(process.cwd() + "/" + options.name + ".config.mjs").then(
(m) => ({
config: m.default,
}),
);
return import(joinURL(
pathToFileURL(process.cwd()).href,
`${options.name}.config.mjs`,
),).then((m) => ({
config: m.default,
}));
}
} else if (options.configFile) {
if (options.configFile.endsWith("js")) {
return import(process.cwd() + "/" + options.configFile).then((m) => ({
return import(joinURL(
pathToFileURL(process.cwd()).href,
`${options.configFile}`,
),).then((m) => ({
config: m.default,
}));
}
Expand Down

0 comments on commit 44fa5ca

Please sign in to comment.