UNPKG

libyear

Version:

A simple measure of software dependency freshness

46 lines (45 loc) 1.58 kB
import { cosmiconfig } from "cosmiconfig"; import { merge } from "lodash-es"; const getCliConfiguration = (args) => ({ threshold: { drift: { collective: (args["threshold-drift-collective"] ?? args["D"]), individual: (args["threshold-drift-individual"] ?? args["d"]), }, pulse: { collective: (args["threshold-pulse-collective"] ?? args["P"]), individual: (args["threshold-pulse-individual"] ?? args["p"]), }, releases: { collective: (args["threshold-releases-collective"] ?? args["R"]), individual: (args["threshold-releases-individual"] ?? args["r"]), }, major: { collective: args["threshold-major-collective"], individual: args["threshold-major-individual"], }, minor: { collective: args["threshold-minor-collective"], individual: args["threshold-minor-individual"], }, patch: { collective: args["threshold-patch-collective"], individual: args["threshold-patch-individual"], }, }, }); const getCosmiconfig = async (filePath) => { const explorer = cosmiconfig("libyear"); try { const result = filePath ? await explorer.load(filePath) : await explorer.search(); return result.config; } catch (error) { return {}; } }; export const getConfiguration = async (args) => merge(await getCosmiconfig(args["config"]), getCliConfiguration(args));