Skip to content

Commit 357e721

Browse files
committed
fix: use full output-path on mdapi convert
1 parent a04af69 commit 357e721

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
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 & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ describe('project convert mdapi NUTs', () => {
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+
expect(result.jsonOutput).to.not.be.undefined;
94+
result.jsonOutput?.result.forEach((md) => {
95+
expect(md.filePath.startsWith(convertedToSrcPath)).to.be.true;
96+
});
9397
});
9498

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

0 commit comments

Comments
 (0)