Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

配置加载使用 proload/cosmiconfig 替换 #378

Closed
jaywcjlove opened this issue Apr 20, 2022 · 1 comment
Closed

配置加载使用 proload/cosmiconfig 替换 #378

jaywcjlove opened this issue Apr 20, 2022 · 1 comment
Assignees

Comments

@jaywcjlove
Copy link
Member

jaywcjlove commented Apr 20, 2022

Stars CI NPM version Coverage Status

Github: https://github.com/jaywcjlove/auto-config-loader
Npm: https://www.npmjs.com/package/auto-config-loader

Github: https://github.com/natemoo-re/proload

export async function loaderConf(rcPath: string): Promise<KKTRC> {
let kktrc: KKTRC = {};
const confJsPath = `${rcPath}.js`;
const confTsPath = `${rcPath}.ts`;
try {
if (fs.existsSync(confTsPath)) {
require('ts-node').register(tsOptions);
kktrc = await import(confTsPath);
return kktrc;
}
if (fs.existsSync(confJsPath)) {
require('@babel/register')({
presets: [[require.resolve('babel-preset-react-app'), { runtime: 'classic', useESModules: false }]],
});
kktrc = await import(confJsPath);
}
return kktrc;
} catch (error) {
const message = error && error.message ? error.message : '';
console.log('Invalid \x1b[31;1m .kktrc.js \x1b[0m file.\n', error);
new Error(`Invalid .kktrc.js file. \n ${message}`);
process.exit(1);
}
}

Github: https://github.com/cosmiconfig/cosmiconfig
Npm: https://www.npmjs.com/package/cosmiconfig

@jaywcjlove jaywcjlove changed the title 配置加载使用 proload 替换 配置加载使用 proload/cosmiconfig 替换 May 27, 2023
@jaywcjlove
Copy link
Member Author

9ef2499 c5e1b97

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants