24 lines
672 B
TypeScript
24 lines
672 B
TypeScript
import path from 'path';
|
|
import fs from 'fs';
|
|
import type { App } from './read-app-schema.ts';
|
|
import { fileURLToPath } from 'url';
|
|
import { getConfigFile } from './config.ts';
|
|
|
|
const __filename = fileURLToPath(import.meta.url); // 当前模块的文件路径
|
|
const __dirname = path.dirname(__filename); // 当前模块的目录路径
|
|
|
|
export const getPkgs = () => {
|
|
const configFile = getConfigFile();
|
|
if (!configFile) {
|
|
console.error('配置文件不存在');
|
|
return {};
|
|
}
|
|
const config = JSON.parse(fs.readFileSync(configFile, 'utf-8'));
|
|
return config;
|
|
};
|
|
|
|
export const getApps = (): App => {
|
|
const config = getPkgs();
|
|
return config.apps || {};
|
|
};
|