From a0e6939e3bb467c131a84a9ce5c9fc286e382f7d Mon Sep 17 00:00:00 2001 From: Damien Butt <22627489+damienbutt@users.noreply.github.com> Date: Wed, 31 Jul 2024 00:22:14 +0100 Subject: [PATCH] refactor: use getModuleName --- lib/utils/getModuleName.ts | 6 ++++++ lib/utils/index.ts | 1 + src/app.ts | 5 +++-- 3 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 lib/utils/getModuleName.ts diff --git a/lib/utils/getModuleName.ts b/lib/utils/getModuleName.ts new file mode 100644 index 0000000..1910a36 --- /dev/null +++ b/lib/utils/getModuleName.ts @@ -0,0 +1,6 @@ +import path from "node:path"; +import { getPackageJson } from "./index.js"; + +export async function getModuleName(): Promise { + return path.basename((await getPackageJson())?.name || "Unknown"); +} diff --git a/lib/utils/index.ts b/lib/utils/index.ts index da84746..4ca4833 100644 --- a/lib/utils/index.ts +++ b/lib/utils/index.ts @@ -3,6 +3,7 @@ export * from "./getAppConfig.js"; export * from "./getAppVersion.js"; export * from "./getGlobalConfig.js"; export * from "./getLocalConfig.js"; +export * from "./getModuleName.js"; export * from "./getPackageJson.js"; export * from "./loadAPW.js"; export * from "./pathExists.js"; diff --git a/src/app.ts b/src/app.ts index b2d0f18..2e51898 100644 --- a/src/app.ts +++ b/src/app.ts @@ -3,15 +3,16 @@ import figlet from "figlet"; import StringBuilder from "string-builder"; import { Command } from "commander"; -import { getAppVersion } from "../lib/utils/index.js"; +import { getAppVersion, getModuleName } from "../lib/utils/index.js"; import { archive, build, cfg, config } from "./commands/index.js"; const args = process.argv; const program = new Command(); +const name = await getModuleName(); const version = await getAppVersion(); program - .name("genlinx") + .name(name) .description("cli helper utility for NetLinx projects 🚀🚀🚀") .version(version, "-v, --version");