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..bc24b87d 100644 --- a/test/nuts/convert/mdapi.nut.ts +++ b/test/nuts/convert/mdapi.nut.ts @@ -82,7 +82,7 @@ describe('project convert mdapi NUTs', () => { expect(fs.existsSync(convertedToSrcPath)).to.be.true; }); - it('should convert the dreamhouse project using metadata flag', () => { + it('should convert the dreamhouse project using metadata flag', async () => { const convertedToSrcPath = path.join(session.dir, 'convertedToSrcPath_metadataFlag'); const result = execCmd( `project:convert:mdapi -r ${convertedToMdPath} -d ${convertedToSrcPath} -m ApexClass --json` @@ -90,6 +90,9 @@ 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; + + const files = await fs.promises.readdir(path.join(convertedToSrcPath, 'main', 'default', 'classes')); + expect(files.length).to.equal(result.jsonOutput?.result.length); }); it('should convert the dreamhouse project using metadatapath flag', () => {