Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tsp - add support for output-folder #1364

Merged
merged 1 commit into from
Jul 30, 2024
Merged
Changes from all commits
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 powershell/utils/model-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ import { Channel, AutorestExtensionHost as Host, JsonPointerSegments as JsonPath
import { safeEval, deserialize, Initializer, DeepPartial } from '@azure-tools/codegen';
import { Dictionary } from '@azure-tools/linq';
import { TspHost, TspHostImpl } from './tsp-host';
import { join } from 'path';

export class ModelState<T extends Dictionary<any>> extends Initializer {
public model!: T;
protected documentName!: string;
protected currentPath: JsonPath = new Array<string>();
protected outputFolder!: string;
private context!: any;
private _debug = false;
private _verbose = false;
Expand All @@ -24,6 +26,7 @@ export class ModelState<T extends Dictionary<any>> extends Initializer {
async init(project?: any) {
if (this.service instanceof TspHostImpl) {
// skip init for tsp
this.outputFolder = await this.getValue('output-folder', './generated');
this.initContext(project);
return this;
}
Expand Down Expand Up @@ -95,7 +98,7 @@ export class ModelState<T extends Dictionary<any>> extends Initializer {
return this.service.protectFiles(path);
}
writeFile(filename: string, content: string, sourceMap?: undefined, artifactType?: string | undefined): void {
return this.service.writeFile({ filename: filename, content: content, sourceMap: sourceMap, artifactType: artifactType });
return this.service.writeFile({ filename: join(this.outputFolder, filename), content: content, sourceMap: sourceMap, artifactType: artifactType });
}

message(message: Message): void {
Expand Down
Loading