diff --git a/tools/tsp-client/CHANGELOG.md b/tools/tsp-client/CHANGELOG.md index c46e5cce146..74d0aff334a 100644 --- a/tools/tsp-client/CHANGELOG.md +++ b/tools/tsp-client/CHANGELOG.md @@ -1,5 +1,9 @@ # Release +## 2024-08-12 - 0.11.2 + +- Fix `--version` flag. (#8814) + ## 2024-08-08 - 0.11.1 - Removed `compare` command. diff --git a/tools/tsp-client/src/index.ts b/tools/tsp-client/src/index.ts index feb82cab6b8..e6d7d20c059 100644 --- a/tools/tsp-client/src/index.ts +++ b/tools/tsp-client/src/index.ts @@ -10,8 +10,15 @@ import { syncCommand, updateCommand, } from "./commands.js"; -import { normalizePath, resolvePath } from "@typespec/compiler"; +import { joinPaths, normalizePath, resolvePath } from "@typespec/compiler"; import PromptSync from "prompt-sync"; +import { readFile } from "fs/promises"; +import { fileURLToPath } from "url"; +import { dirname } from "path"; + +const __dirname = dirname(fileURLToPath(import.meta.url)); + +const { version } = JSON.parse(await readFile(joinPaths(__dirname, "..", "package.json"), "utf8")); function commandPreamble(argv: any) { checkDebugLogging(argv); @@ -49,6 +56,8 @@ export function resolveOutputDir(argv: any): string { } const parser = yargs(hideBin(process.argv)) + .version(version) + .alias("v", "version") .scriptName("") .usage(usageText) .option("debug", {