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 all commits
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;
}
}
};
5 changes: 4 additions & 1 deletion test/nuts/convert/mdapi.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,17 @@ 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<ConvertMdapiJson>(
`project:convert:mdapi -r ${convertedToMdPath} -d ${convertedToSrcPath} -m ApexClass --json`
);
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', () => {
Expand Down
Loading