Skip to content

Commit 9236cbc

Browse files
committed
use const instead of magic string
1 parent 81a5b4f commit 9236cbc

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

packages/typespec-rust/src/codegen/helpers.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@ import { Use } from './use.js';
88
import * as rust from '../codemodel/index.js';
99
import * as utils from '../utils/utils.js';
1010

11+
/** the key phrase used in the generated code header */
12+
export const generatedCodeKeyPhrase = 'Rust Code Generator';
13+
1114
const headerText = `// Copyright (c) Microsoft Corporation. All rights reserved.
1215
// Licensed under the MIT License.
1316
//
14-
// Code generated by Microsoft (R) Rust Code Generator.`;
17+
// Code generated by Microsoft (R) ${generatedCodeKeyPhrase}.`;
1518

1619
export const AnnotationNonExhaustive = '#[non_exhaustive]\n';
1720

packages/typespec-rust/src/emitter.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import { CodeGenerator } from './codegen/codeGenerator.js';
99
import { CodegenError } from './codegen/errors.js';
10+
import { generatedCodeKeyPhrase } from './codegen/helpers.js';
1011
import { Adapter, AdapterError, ExternalError } from './tcgcadapter/adapter.js';
1112
import { reportDiagnostic, RustEmitterOptions } from './lib.js';
1213
import { execSync } from 'child_process';
@@ -188,5 +189,5 @@ function shouldRmDir(dirName: string): boolean {
188189
return false;
189190
}
190191
const content = fs.readFileSync(modRs, { encoding: 'utf-8' });
191-
return content.match(/Rust Code Generator/) !== null;
192+
return content.match(generatedCodeKeyPhrase) !== null;
192193
}

0 commit comments

Comments
 (0)