Skip to content

Commit

Permalink
feat: pass projectDir down from ComponentSet
Browse files Browse the repository at this point in the history
  • Loading branch information
mshanemc committed Mar 27, 2023
1 parent fe9a499 commit 519bc34
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/convert/convertContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,11 +322,13 @@ export class ConvertContext {
public readonly recomposition = new RecompositionFinalizer();
public readonly nonDecomposition = new NonDecompositionFinalizer();

public constructor(private readonly projectDirectory?: string) {}

// eslint-disable-next-line @typescript-eslint/require-await
public async *executeFinalizers(defaultDirectory?: string): AsyncIterable<WriterFormat[]> {
for (const member of Object.values(this)) {
if (member instanceof ConvertTransactionFinalizer) {
yield member.finalize(defaultDirectory);
yield member.finalize(defaultDirectory ?? this.projectDirectory);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/convert/metadataConverter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export class MetadataConverter {
!targetFormatIsSource && (process.env.SF_APPLY_REPLACEMENTS_ON_CONVERT === 'true' || output.type === 'zip')
? (await getReplacementMarkingStream(cs.projectDirectory)) ?? new PassThrough({ objectMode: true })
: new PassThrough({ objectMode: true }),
new ComponentConverter(targetFormat, this.registry, mergeSet, defaultDirectory),
new ComponentConverter(targetFormat, this.registry, mergeSet, defaultDirectory, cs.projectDirectory),
writer
);
await Promise.all([conversionPipeline, ...tasks]);
Expand Down
6 changes: 4 additions & 2 deletions src/convert/streams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,18 @@ export const stream2buffer = async (stream: Stream): Promise<Buffer> =>
});

export class ComponentConverter extends Transform {
public readonly context = new ConvertContext();
public readonly context: ConvertContext;
private transformerFactory: MetadataTransformerFactory;

public constructor(
private targetFormat: SfdxFileFormat,
registry: RegistryAccess,
private mergeSet?: ComponentSet,
private defaultDirectory?: string
private defaultDirectory?: string,
projectDirectory?: string
) {
super({ objectMode: true });
this.context = new ConvertContext(projectDirectory);
this.transformerFactory = new MetadataTransformerFactory(registry, this.context);
}

Expand Down

0 comments on commit 519bc34

Please sign in to comment.