Skip to content

Commit 8c5b9fd

Browse files
committed
fix: deployResponses for non-set cwd
1 parent c53906a commit 8c5b9fd

File tree

2 files changed

+29
-17
lines changed

2 files changed

+29
-17
lines changed

src/client/deployMessages.ts

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -79,22 +79,31 @@ const shouldWalkContent = (component: SourceComponent): boolean =>
7979
(t) => t.unaddressableWithoutParent === true || t.isAddressable === false
8080
));
8181

82-
export const createResponses = (component: SourceComponent, responseMessages: DeployMessage[]): FileResponse[] =>
83-
responseMessages.flatMap((message): FileResponse[] => {
84-
const state = getState(message);
85-
const base = { fullName: component.fullName, type: component.type.name } as const;
82+
export const createResponses =
83+
(projectPath?: string) =>
84+
(component: SourceComponent, responseMessages: DeployMessage[]): FileResponse[] =>
85+
responseMessages.flatMap((message): FileResponse[] => {
86+
const state = getState(message);
87+
const base = { fullName: component.fullName, type: component.type.name } as const;
8688

87-
if (state === ComponentStatus.Failed) {
88-
return [{ ...base, state, ...parseDeployDiagnostic(component, message) } satisfies FileResponseFailure];
89-
} else {
90-
return [
91-
...(shouldWalkContent(component)
92-
? component.walkContent().map((filePath): FileResponseSuccess => ({ ...base, state, filePath }))
93-
: []),
94-
...(component.xml ? [{ ...base, state, filePath: component.xml } satisfies FileResponseSuccess] : []),
95-
];
96-
}
97-
});
89+
if (state === ComponentStatus.Failed) {
90+
return [{ ...base, state, ...parseDeployDiagnostic(component, message) } satisfies FileResponseFailure];
91+
} else {
92+
return [
93+
...(shouldWalkContent(component)
94+
? component.walkContent().map(
95+
(filePath): FileResponseSuccess => ({
96+
...base,
97+
state,
98+
// deployResults will produce filePaths relative to cwd, which might not be set in all environments
99+
filePath: process.cwd() === projectPath ? filePath : join(projectPath ?? '', filePath),
100+
})
101+
)
102+
: []),
103+
...(component.xml ? [{ ...base, state, filePath: component.xml } satisfies FileResponseSuccess] : []),
104+
];
105+
}
106+
});
98107
/**
99108
* Groups messages from the deploy result by component fullName and type
100109
*/

src/client/metadataApiDeploy.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -509,11 +509,14 @@ const buildFileResponsesFromComponentSet =
509509

510510
const fileResponses = (cs.getSourceComponents().toArray() ?? [])
511511
.flatMap((deployedComponent) =>
512-
createResponses(deployedComponent, responseMessages.get(toKey(deployedComponent)) ?? []).concat(
512+
createResponses(cs.projectDirectory)(
513+
deployedComponent,
514+
responseMessages.get(toKey(deployedComponent)) ?? []
515+
).concat(
513516
deployedComponent.type.children
514517
? deployedComponent.getChildren().flatMap((child) => {
515518
const childMessages = responseMessages.get(toKey(child));
516-
return childMessages ? createResponses(child, childMessages) : [];
519+
return childMessages ? createResponses(cs.projectDirectory)(child, childMessages) : [];
517520
})
518521
: []
519522
)

0 commit comments

Comments
 (0)