diff --git a/src/org/scratchOrgInfoGenerator.ts b/src/org/scratchOrgInfoGenerator.ts index c4a7ef505..392147e23 100644 --- a/src/org/scratchOrgInfoGenerator.ts +++ b/src/org/scratchOrgInfoGenerator.ts @@ -322,6 +322,8 @@ const parseDefinitionFile = async (definitionFile: string): Promise; + // remove key '$schema' from the definition file + delete defFileContents['$schema']; return defFileContents; } catch (err) { const error = err as Error; diff --git a/test/unit/org/scratchOrgInfoGenerator.test.ts b/test/unit/org/scratchOrgInfoGenerator.test.ts index 784c1d6fc..f3f7dfcef 100644 --- a/test/unit/org/scratchOrgInfoGenerator.test.ts +++ b/test/unit/org/scratchOrgInfoGenerator.test.ts @@ -1026,5 +1026,25 @@ describe('scratchOrgInfoGenerator', () => { expect(err).to.exist; } }); + it('Remove $schema key if it exist', async () => { + sandbox.restore(); + stubMethod(sandbox, fs.promises, 'readFile') + .withArgs('./my-file.json', 'utf8') + .resolves( + '{ "$schema": "https://forcedotcom.github.io/schemas/project-scratch-def.json/project-scratch-def.schema.json" }' + ); + expect( + await getScratchOrgInfoPayload({ + durationDays: 1, + definitionfile: './my-file.json', + }) + ).to.deep.equal({ + scratchOrgInfoPayload: { + durationDays: 1, + }, + ignoreAncestorIds: false, + warnings: [], + }); + }); }); });