mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 17:36:08 +08:00
22 lines
609 B
TypeScript
22 lines
609 B
TypeScript
import Zip from 'adm-zip';
|
|
|
|
async function readConfig(filePath: string) {
|
|
const data = new Zip(filePath);
|
|
const entries = data.getEntries();
|
|
for (const entry of entries) {
|
|
if (entry.name.toLowerCase() === 'config.yaml') {
|
|
return entry.getData().toString();
|
|
}
|
|
if (entry.name.toLowerCase() === 'config.ini') {
|
|
const ini = entry.getData().toString();
|
|
const conv = global.Hydro.lib['testdata.convert.ini'];
|
|
return conv(ini);
|
|
}
|
|
}
|
|
return '';
|
|
}
|
|
|
|
global.Hydro.lib.readConfig = readConfig;
|
|
|
|
export default readConfig;
|