fix: fix bugs
This commit is contained in:
		@@ -1,6 +1,6 @@
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
  "name": "@kevisual/use-config",
 | 
					  "name": "@kevisual/use-config",
 | 
				
			||||||
  "version": "1.0.12",
 | 
					  "version": "1.0.13",
 | 
				
			||||||
  "types": "dist/config.d.ts",
 | 
					  "types": "dist/config.d.ts",
 | 
				
			||||||
  "scripts": {
 | 
					  "scripts": {
 | 
				
			||||||
    "build": "npm run clean && tsup",
 | 
					    "build": "npm run clean && tsup",
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,6 +1,8 @@
 | 
				
			|||||||
import fs from 'fs';
 | 
					import fs from 'fs';
 | 
				
			||||||
import path from 'path';
 | 
					import path from 'path';
 | 
				
			||||||
import dotenv from 'dotenv';
 | 
					import dotenv from 'dotenv';
 | 
				
			||||||
 | 
					import { fileURLToPath } from 'url';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// 配置类型
 | 
					// 配置类型
 | 
				
			||||||
export type Config = {
 | 
					export type Config = {
 | 
				
			||||||
  PORT: number;
 | 
					  PORT: number;
 | 
				
			||||||
@@ -208,6 +210,7 @@ export const readJsonConfig = (opts?: Omit<ConfigOpts, 'envConfigFile'>) => {
 | 
				
			|||||||
 * @returns
 | 
					 * @returns
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
export const resolvePath = (releactivePath: string = '') => {
 | 
					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);
 | 
					  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);
 | 
				
			||||||
		Reference in New Issue
	
	Block a user