fix: fix bugs

This commit is contained in:
熊潇 2025-05-01 01:48:35 +08:00
parent cf570cd35b
commit 751b874fd4
3 changed files with 10 additions and 2 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@kevisual/use-config",
"version": "1.0.12",
"version": "1.0.13",
"types": "dist/config.d.ts",
"scripts": {
"build": "npm run clean && tsup",

View File

@ -1,6 +1,8 @@
import fs from 'fs';
import path from 'path';
import dotenv from 'dotenv';
import { fileURLToPath } from 'url';
// 配置类型
export type Config = {
PORT: number;
@ -208,6 +210,7 @@ export const readJsonConfig = (opts?: Omit<ConfigOpts, 'envConfigFile'>) => {
* @returns
*/
export const resolvePath = (releactivePath: string = '') => {
const __dirname = import.meta.url ? path.dirname(import.meta.url) : '';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
return path.resolve(__dirname, releactivePath);
};

5
src/test/resolve.ts Normal file
View File

@ -0,0 +1,5 @@
import { resolvePath } from '@/env.ts';
const path = resolvePath('src/test/resolve.ts');
console.log('path', path);