Skip to content

Commit

Permalink
[tcgc] support new typespec emitter naming rule (#947)
Browse files Browse the repository at this point in the history
resolve: #937
  • Loading branch information
tadelesh authored Jun 4, 2024
1 parent 8713698 commit 414e3b2
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
7 changes: 7 additions & 0 deletions .chronus/changes/emitter_name-2024-5-3-22-57-49.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: fix
packages:
- "@azure-tools/typespec-client-generator-core"
---

support new typespec emitter naming rule
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export function parseEmitterName(
);
return diagnostics.wrap("none");
}
const regex = /(?:cadl|typespec)-([^\\/]*)/;
const regex = /(?:cadl|typespec|client|server)-([^\\/-]*)/;
const match = emitterName.match(regex);
if (!match || match.length < 2) return diagnostics.wrap("none");
const language = match[1];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,17 @@ describe("typespec-client-generator-core: internal-utils", () => {
strictEqual(docHelper.details, "This is a description");
});
});
describe("parseEmitterName", () => {
it("@azure-tools/typespec-{language}", async () => {
const runner = await createSdkTestRunner({ emitterName: "@azure-tools/typespec-csharp" });
await runner.compile("");
strictEqual(runner.context.emitterName, "csharp");
});

it("@typespec/{protocol}-{client|server}-{language}-generator", async () => {
const runner = await createSdkTestRunner({ emitterName: "@typespec/http-client-csharp" });
await runner.compile("");
strictEqual(runner.context.emitterName, "csharp");
});
});
});

0 comments on commit 414e3b2

Please sign in to comment.