Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion tools/tsp-client/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,14 +219,17 @@ async function generate({
args.push("--force");
}
await npmCommand(srcDir, args);
await compileTsp({ emitterPackage: emitter, outputPath: rootUrl, resolvedMainFilePath, saveInputs: noCleanup, additionalEmitterOptions });
const succeeded = await compileTsp({ emitterPackage: emitter, outputPath: rootUrl, resolvedMainFilePath, saveInputs: noCleanup, additionalEmitterOptions });

if (noCleanup) {
Logger.debug(`Skipping cleanup of temp directory: ${tempRoot}`);
} else {
Logger.debug("Cleaning up temp directory");
await removeDirectory(tempRoot);
}
if (!succeeded) {
exit(1);
}
}


Expand Down
8 changes: 5 additions & 3 deletions tools/tsp-client/src/typespec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export async function compileTsp({
resolvedMainFilePath: string;
additionalEmitterOptions?: string;
saveInputs?: boolean;
}) {
}): Promise<boolean> {
const parsedEntrypoint = getDirectoryPath(resolvedMainFilePath);
const { compile, NodeHost, resolveCompilerOptions } = await importTsp(parsedEntrypoint);

Expand Down Expand Up @@ -100,7 +100,8 @@ export async function compileTsp({
Logger.debug(`Compiler options: ${JSON.stringify(options)}`);
if (diagnostics.length > 0) {
// This should not happen, but if it does, we should log it.
Logger.debug(`Compiler options diagnostic information: ${JSON.stringify(diagnostics)}`);
Logger.error(`Compiler options diagnostic information: ${JSON.stringify(diagnostics)}`);
return false;
}

const program = await compile(NodeHost, resolvedMainFilePath, options);
Expand All @@ -109,10 +110,11 @@ export async function compileTsp({
for (const diagnostic of program.diagnostics) {
Logger.error(formatDiagnostic(diagnostic));
}
process.exit(1);
return false;
} else {
Logger.success("generation complete");
}
return true;
}

export async function importTsp(baseDir: string): Promise<typeof import("@typespec/compiler")> {
Expand Down