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",
"version": "1.0.13",
"version": "1.0.15",
"types": "dist/config.d.ts",
"scripts": {
"build": "npm run clean && tsup",

View File

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