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