Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use full output-path on convert mdapi #1091

Merged
merged 2 commits into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This NUT was testing that the output dir was created in L92 (which is true) but the metadata was still written to the first dir in the path.

Screenshot 2024-07-15 at 7 29 28 PM

});
});

it('should convert the dreamhouse project using metadatapath flag', () => {
Expand Down
Loading