diff --git a/src/componentSetBuilder.ts b/src/componentSetBuilder.ts index 0b9fc7fce..04e3d9e13 100644 --- a/src/componentSetBuilder.ts +++ b/src/componentSetBuilder.ts @@ -80,7 +80,7 @@ export class ComponentSetBuilder { // Build a Set of metadata entries metadata.metadataEntries.forEach((rawEntry) => { - const splitEntry = rawEntry.split(':'); + const splitEntry = rawEntry.split(':').map((entry) => entry.trim()); // The registry will throw if it doesn't know what this type is. registry.getTypeByName(splitEntry[0]); const entry = { diff --git a/test/commands/source/componentSetBuilder.test.ts b/test/commands/source/componentSetBuilder.test.ts index 2873c4725..5794964ed 100644 --- a/test/commands/source/componentSetBuilder.test.ts +++ b/test/commands/source/componentSetBuilder.test.ts @@ -177,6 +177,31 @@ describe('ComponentSetBuilder', () => { expect(compSet.has({ type: 'ApexClass', fullName: '*' })).to.equal(true); }); + it('should create ComponentSet from metadata with spaces between : (ApexClass: MyApexClass)', async () => { + componentSet.add(apexClassComponent); + fromSourceStub.returns(componentSet); + const packageDir1 = path.resolve('force-app'); + + const compSet = await ComponentSetBuilder.build({ + sourcepath: undefined, + manifest: undefined, + metadata: { + metadataEntries: ['ApexClass: MyApexClass'], + directoryPaths: [packageDir1], + }, + }); + expect(fromSourceStub.calledOnce).to.equal(true); + const fromSourceArgs = fromSourceStub.firstCall.args[0] as FromSourceOptions; + expect(fromSourceArgs).to.have.deep.property('fsPaths', [packageDir1]); + const filter = new ComponentSet(); + filter.add({ type: 'ApexClass', fullName: 'MyApexClass' }); + expect(fromSourceArgs).to.have.property('include'); + expect(fromSourceArgs.include.getSourceComponents()).to.deep.equal(filter.getSourceComponents()); + expect(compSet.size).to.equal(2); + expect(compSet.has(apexClassComponent)).to.equal(true); + expect(compSet.has({ type: 'ApexClass', fullName: 'MyApexClass' })).to.equal(true); + }); + it('should throw an error when it cant resolve a metadata type (Metadata)', async () => { const packageDir1 = path.resolve('force-app');