fix: fix bugs
This commit is contained in:
parent
751b874fd4
commit
956114e891
@ -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",
|
||||
|
21
src/env.ts
21
src/env.ts
@ -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);
|
||||
}
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user