tangled
alpha
login
or
join now
danabra.mov
/
typelex
56
fork
atom
An experimental TypeSpec syntax for Lexicon
56
fork
atom
overview
issues
1
pulls
2
pipelines
more descriptive
danabra.mov
5 months ago
aad5b08d
dc593920
+5
-5
2 changed files
expand all
collapse all
unified
split
packages
cli
src
utils
externals-generator.ts
example
typelex
externals.tsp
+4
-4
packages/cli/src/utils/externals-generator.ts
···
22
22
/**
23
23
* Generate TypeSpec external definitions from lexicon documents
24
24
*/
25
25
-
function generateExternalsCode(lexicons: Map<string, LexiconDoc>): string {
25
25
+
function generateExternalsCode(lexicons: Map<string, LexiconDoc>, outDir: string, excludedPrefix: string): string {
26
26
const lines: string[] = [];
27
27
28
28
lines.push('import "@typelex/emitter";');
29
29
lines.push("");
30
30
-
lines.push("// Generated by typelex");
30
30
+
lines.push(`// Generated by typelex from ${outDir} (excluding ${excludedPrefix}.*)`);
31
31
lines.push("// This file is auto-generated. Do not edit manually.");
32
32
lines.push("");
33
33
···
89
89
await mkdir(resolve(cwd, "typelex"), { recursive: true });
90
90
await writeFile(
91
91
outputFile,
92
92
-
'import "@typelex/emitter";\n\n// Generated by typelex\n// No external lexicons found\n',
92
92
+
`import "@typelex/emitter";\n\n// Generated by typelex from ${outDir} (excluding ${prefix}.*)\n// No external lexicons found\n`,
93
93
"utf-8"
94
94
);
95
95
return;
96
96
}
97
97
98
98
-
const code = generateExternalsCode(externals);
98
98
+
const code = generateExternalsCode(externals, outDir, prefix);
99
99
await mkdir(resolve(cwd, "typelex"), { recursive: true });
100
100
await writeFile(outputFile, code, "utf-8");
101
101
} catch (error) {
+1
-1
packages/example/typelex/externals.tsp
···
1
1
import "@typelex/emitter";
2
2
3
3
-
// Generated by typelex
3
3
+
// Generated by typelex from ./lexicons (excluding xyz.statusphere.*)
4
4
// This file is auto-generated. Do not edit manually.
5
5
6
6
@external