fix: fix bugs
This commit is contained in:
parent
cf570cd35b
commit
751b874fd4
@ -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",
|
||||
|
@ -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
5
src/test/resolve.ts
Normal file
@ -0,0 +1,5 @@
|
||||
import { resolvePath } from '@/env.ts';
|
||||
|
||||
const path = resolvePath('src/test/resolve.ts');
|
||||
|
||||
console.log('path', path);
|
Loading…
x
Reference in New Issue
Block a user