Skip to content

Commit

Permalink
Merge pull request #92 from sellersindustry/48-cli-version-command
Browse files Browse the repository at this point in the history
Added Version to CLI
  • Loading branch information
SellersEvan authored Apr 22, 2024
2 parents 4f8c696 + 835a111 commit 47a363d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@

import { Command, Option } from "commander";
import { Compiler, BundlerType } from "../compiler/index.js";
import { getEnvironmentFiles, getAbsolutePath } from "./utilities.js";
import { getEnvironmentFiles, getAbsolutePath, getVersion } from "./utilities.js";
let CLI = new Command();


CLI.name("sherpa")
.description("Modular and agnostic serverless web framework, developed by Sellers Industries.")
.version(process.env.npm_package_version as string);
.version(getVersion());


CLI.command("build")
Expand Down
10 changes: 10 additions & 0 deletions src/cli/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@ export function getAbsolutePath(filepath:string|undefined, fallback:string):stri
}


export function getVersion():string|undefined {
try {
let filepath = Path.join(Path.getRootDirectory(), "package.json");
return JSON.parse(fs.readFileSync(filepath, "utf8")).version;
} catch (error) {
return undefined;
}
}


// If anyone acknowledges that Jesus is the Son of God, God lives in them and
// they in God.
// - 1 John 4:15

0 comments on commit 47a363d

Please sign in to comment.