mirror of
https://github.com/wavetermdev/inshellisense.git
synced 2026-08-05 13:43:30 -07:00
fix: have version flag track package.json version
Signed-off-by: Chapman Pendery <cpendery@vt.edu>
This commit is contained in:
+2
-1
@@ -9,13 +9,14 @@ import { Command } from "commander";
|
||||
|
||||
import bind from "./commands/bind.js";
|
||||
import { action, supportedShells } from "./commands/root.js";
|
||||
import { getVersion } from "./utils/version.js";
|
||||
|
||||
const program = new Command();
|
||||
|
||||
program
|
||||
.name("inshellisense")
|
||||
.description("IDE style command line auto complete")
|
||||
.version("0.0.0", "-v, --version", "output the current version")
|
||||
.version(await getVersion(), "-v, --version", "output the current version")
|
||||
.option("-s, --shell <shell>", `shell to use for command execution, supported shells: ${supportedShells}`)
|
||||
.option("-c, --command <commmand>", "command to use as initial input")
|
||||
.option("--history", "get the last command execute")
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
import url from "node:url";
|
||||
import path from "node:path";
|
||||
import fsAsync from "node:fs/promises";
|
||||
|
||||
const __filename = url.fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
|
||||
export const getVersion = async (): Promise<string> => {
|
||||
const packageJsonPath = path.join(__dirname, "..", "..", "package.json");
|
||||
const packageJson = await fsAsync.readFile(packageJsonPath, { encoding: "utf-8" });
|
||||
const packageJsonParsed = JSON.parse(packageJson);
|
||||
return packageJsonParsed.version;
|
||||
};
|
||||
Reference in New Issue
Block a user