UNPKG

t-comm

Version:

专业、稳定、纯粹的工具库

24 lines (21 loc) 576 B
import { readFileSync } from '../fs/fs.mjs'; import { getPath } from '../nodejs/path.mjs'; import '../nodejs/crypto.mjs'; import '../nodejs/fs.mjs'; import '../nodejs/os.mjs'; /** * 获取依赖列表 * @param dir 目录 * @returns dependenciesList * @example * ```ts * // 假设 ./package.json 中 dependencies 包含 axios、lodash * getDeps('./'); * // ['axios', 'lodash'] * ``` */ function getDeps(dir) { var data = readFileSync(getPath().resolve(dir, 'package.json'), true); return Object.keys(Object.assign({}, data.dependencies)); } export { getDeps };