Skip to content

Commit d1aa2a3

Browse files
Merge pull request #1091 from salesforcecli/cd/fix-output-dir
fix: use full output-path on `convert mdapi`
2 parents 71efd6e + 1e264d6 commit d1aa2a3

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/commands/project/convert/mdapi.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,13 @@ const ensureFlagPath = async (options: EnsureFsFlagOptions): Promise<string> =>
202202
throw new SfError(messages.getMessage('InvalidFlagPath', [flagName, path, enoent]), 'InvalidFlagPath');
203203
}
204204
const dir = type === 'dir' ? resolvedPath : dirname(resolvedPath);
205-
// using as because fs promises always returns a string when recursive is true
206-
return fs.promises.mkdir(dir, { recursive: true }) as Promise<string>;
205+
206+
await fs.promises.mkdir(dir, { recursive: true }).catch((err) => {
207+
throw SfError.wrap(err);
208+
});
209+
210+
// `fs.mkdir` will return only the first dir in the path so we return the full path here
211+
return dir;
207212
}
208213
}
209214
};

test/nuts/convert/mdapi.nut.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,17 @@ describe('project convert mdapi NUTs', () => {
8282
expect(fs.existsSync(convertedToSrcPath)).to.be.true;
8383
});
8484

85-
it('should convert the dreamhouse project using metadata flag', () => {
85+
it('should convert the dreamhouse project using metadata flag', async () => {
8686
const convertedToSrcPath = path.join(session.dir, 'convertedToSrcPath_metadataFlag');
8787
const result = execCmd<ConvertMdapiJson>(
8888
`project:convert:mdapi -r ${convertedToMdPath} -d ${convertedToSrcPath} -m ApexClass --json`
8989
);
9090
expect(result.jsonOutput?.status).to.equal(0);
9191
expect(result.jsonOutput?.result).to.be.an('array').with.length.greaterThan(10);
9292
expect(fs.existsSync(convertedToSrcPath)).to.be.true;
93+
94+
const files = await fs.promises.readdir(path.join(convertedToSrcPath, 'main', 'default', 'classes'));
95+
expect(files.length).to.equal(result.jsonOutput?.result.length);
9396
});
9497

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

0 commit comments

Comments
 (0)