Skip to content

Commit 67b5775

Browse files
authored
Sm/file-responses-windows-paths-bug (#579)
* fix: message keys should use posix paths * test: handle windows separators in Fullname for folder types * chore: adding types for SDR
1 parent e25dd95 commit 67b5775

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/client/metadataApiDeploy.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Licensed under the BSD 3-Clause license.
55
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
66
*/
7-
import { basename, dirname, extname, join } from 'path';
7+
import { basename, dirname, extname, join, posix, sep } from 'path';
88
import { isString } from '@salesforce/ts-types';
99
import { create as createArchive } from 'archiver';
1010
import * as fs from 'graceful-fs';
@@ -30,6 +30,7 @@ export class DeployResult implements MetadataTransferResult {
3030
public readonly response: MetadataApiDeployStatus;
3131
public readonly components: ComponentSet;
3232
private readonly diagnosticUtil = new DiagnosticUtil('metadata');
33+
private readonly shouldConvertPaths = sep !== posix.sep;
3334

3435
public constructor(response: MetadataApiDeployStatus, components: ComponentSet) {
3536
this.response = response;
@@ -215,7 +216,7 @@ export class DeployResult implements MetadataTransferResult {
215216

216217
private key(component: ComponentLike): string {
217218
const type = typeof component.type === 'string' ? component.type : component.type.name;
218-
return `${type}#${component.fullName}`;
219+
return `${type}#${this.shouldConvertPaths ? component.fullName.split(sep).join(posix.sep) : component.fullName}`;
219220
}
220221
}
221222

test/client/metadataApiDeploy.test.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -367,13 +367,16 @@ describe('MetadataApiDeploy', () => {
367367
expect(responses).to.deep.equal(expected);
368368
});
369369

370+
// folder types have a name like TestFolder/TestImageDoc
371+
// which may include a platform-specific separator TestFolder\\TestImageDoc
370372
it('should fix deploy message issue for "Document" type', () => {
371373
const type = registry.types.document;
372374
const name = 'test';
375+
const foldername = 'A_Folder';
373376
const contentName = `${name}.xyz`;
374-
const basePath = join('path', 'to', type.directoryName, 'A_Folder');
377+
const basePath = join('path', 'to', type.directoryName, foldername);
375378
const props = {
376-
name: 'test',
379+
name: join(foldername, name),
377380
type,
378381
xml: join(basePath, `${name}.document${META_XML_SUFFIX}`),
379382
content: join(basePath, contentName),
@@ -393,7 +396,7 @@ describe('MetadataApiDeploy', () => {
393396
deleted: 'false',
394397
success: 'true',
395398
// fullname contains file extension that must be stripped
396-
fullName: contentName,
399+
fullName: join(foldername, name),
397400
componentType: type.name,
398401
} as DeployMessage,
399402
},

0 commit comments

Comments
 (0)