From 357e721b320445dbeae113ecfba99059e5245e92 Mon Sep 17 00:00:00 2001 From: Cristian Dominguez Date: Mon, 15 Jul 2024 19:24:06 -0300 Subject: [PATCH] fix: use full output-path on `mdapi convert` --- src/commands/project/convert/mdapi.ts | 9 +++++++-- test/nuts/convert/mdapi.nut.ts | 4 ++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/commands/project/convert/mdapi.ts b/src/commands/project/convert/mdapi.ts index 6df641c8..d794279d 100644 --- a/src/commands/project/convert/mdapi.ts +++ b/src/commands/project/convert/mdapi.ts @@ -202,8 +202,13 @@ const ensureFlagPath = async (options: EnsureFsFlagOptions): Promise => throw new SfError(messages.getMessage('InvalidFlagPath', [flagName, path, enoent]), 'InvalidFlagPath'); } const dir = type === 'dir' ? resolvedPath : dirname(resolvedPath); - // using as because fs promises always returns a string when recursive is true - return fs.promises.mkdir(dir, { recursive: true }) as Promise; + + await fs.promises.mkdir(dir, { recursive: true }).catch((err) => { + throw SfError.wrap(err); + }); + + // `fs.mkdir` will return only the first dir in the path so we return the full path here + return dir; } } }; diff --git a/test/nuts/convert/mdapi.nut.ts b/test/nuts/convert/mdapi.nut.ts index 02ef44ff..ff267106 100644 --- a/test/nuts/convert/mdapi.nut.ts +++ b/test/nuts/convert/mdapi.nut.ts @@ -90,6 +90,10 @@ describe('project convert mdapi NUTs', () => { expect(result.jsonOutput?.status).to.equal(0); expect(result.jsonOutput?.result).to.be.an('array').with.length.greaterThan(10); expect(fs.existsSync(convertedToSrcPath)).to.be.true; + expect(result.jsonOutput).to.not.be.undefined; + result.jsonOutput?.result.forEach((md) => { + expect(md.filePath.startsWith(convertedToSrcPath)).to.be.true; + }); }); it('should convert the dreamhouse project using metadatapath flag', () => {