diff --git a/tools/tsp-client/src/commands.ts b/tools/tsp-client/src/commands.ts index 45a0fee9dfc..67e9f6f6daa 100644 --- a/tools/tsp-client/src/commands.ts +++ b/tools/tsp-client/src/commands.ts @@ -27,8 +27,8 @@ export async function initCommand(argv: any) { let outputDir = argv["output-dir"]; let tspConfig = argv["tsp-config"]; const skipSyncAndGenerate = argv["skip-sync-and-generate"]; - const commit = argv["commit"]; - const repo = argv["repo"]; + const commit = argv["commit"] ?? ""; + const repo = argv["repo"] ?? ""; const repoRoot = await getRepoRoot(outputDir); @@ -40,16 +40,16 @@ export async function initCommand(argv: any) { } let isUrl = true; - if (await doesFileExist(tspConfig)) { - isUrl = false; - } - if (!isUrl) { - if (!commit || !repo) { - Logger.error("--commit and --repo are required when --tsp-config is a local directory"); - process.exit(1); + if (argv["local-spec-repo"]) { + const localSpecRepo = argv["local-spec-repo"]; + if (!(await doesFileExist(localSpecRepo))) { + throw new Error(`Local spec repo not found: ${localSpecRepo}`); } + isUrl = false; + tspConfig = localSpecRepo; + } else if (await doesFileExist(tspConfig)) { + isUrl = false; } - if (isUrl) { // URL scenario const resolvedConfigUrl = resolveTspConfigUrl(tspConfig);