fix: fix bugs

This commit is contained in:
熊潇 2025-05-05 15:38:28 +08:00
parent 751b874fd4
commit 956114e891
2 changed files with 18 additions and 5 deletions

View File

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

View File

@ -204,13 +204,26 @@ export const readJsonConfig = (opts?: Omit<ConfigOpts, 'envConfigFile'>) => {
return {}; return {};
} }
}; };
type ResolvePathOptions = {
meta?: {
url: string;
};
cwd?: string;
};
/** /**
* path * path
* @param releactivePath * @param releactivePath
* @returns * @returns
*/ */
export const resolvePath = (releactivePath: string = '') => { export const resolvePath = (releactivePath: string = '', opts?: ResolvePathOptions) => {
const __filename = fileURLToPath(import.meta.url); if (opts?.meta) {
const __dirname = path.dirname(__filename); const __filename = fileURLToPath(opts.meta.url);
return path.resolve(__dirname, releactivePath); const __dirname = path.dirname(__filename);
return path.resolve(__dirname, releactivePath);
} else if (opts?.cwd) {
return path.resolve(opts.cwd, releactivePath);
} else {
return path.resolve(getDirname(), releactivePath);
}
}; };