Skip to content

Commit

Permalink
refactor: use getModuleName
Browse files Browse the repository at this point in the history
  • Loading branch information
damienbutt committed Jul 30, 2024
1 parent cbc59c6 commit a0e6939
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
6 changes: 6 additions & 0 deletions lib/utils/getModuleName.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import path from "node:path";
import { getPackageJson } from "./index.js";

export async function getModuleName(): Promise<string> {
return path.basename((await getPackageJson())?.name || "Unknown");
}
1 change: 1 addition & 0 deletions lib/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
5 changes: 3 additions & 2 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down

0 comments on commit a0e6939

Please sign in to comment.