Skip to content

Commit

Permalink
fix: use full output-path on mdapi convert
Browse files Browse the repository at this point in the history
  • Loading branch information
cristiand391 committed Jul 15, 2024
1 parent a04af69 commit 357e721
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/commands/project/convert/mdapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,13 @@ const ensureFlagPath = async (options: EnsureFsFlagOptions): Promise<string> =>
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<string>;

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;
}
}
};
4 changes: 4 additions & 0 deletions test/nuts/convert/mdapi.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down

0 comments on commit 357e721

Please sign in to comment.