Skip to content

Commit

Permalink
Fixing issue while reading multiple directories (#180)
Browse files Browse the repository at this point in the history
* Fixing issue while reading multiple directories

* Fixing issue while reading multiple directories

* releasing version
  • Loading branch information
cesarParra authored Sep 19, 2024
1 parent 6ca4641 commit fa40111
Show file tree
Hide file tree
Showing 17 changed files with 625 additions and 5 deletions.
572 changes: 570 additions & 2 deletions examples/open-api/docs/openapi.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cparra/apexdocs",
"version": "3.1.0",
"version": "3.1.1",
"description": "Library with CLI capabilities to generate documentation for Salesforce Apex classes.",
"keywords": [
"apex",
Expand Down
52 changes: 52 additions & 0 deletions src/application/__tests__/apex-file-reader.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,56 @@ describe('File Reader', () => {
expect(result[0].content).toBe('public class MyClass{}');
expect(result[1].content).toBe('public class AnotherClass{}');
});

it('returns the file contents for all Apex when there are multiple directories', async () => {
const fileSystem = new TestFileSystem([
{
type: 'directory',
path: '',
files: [
{
type: 'file',
path: 'SomeFile.cls',
content: 'public class MyClass{}',
},
{
type: 'directory',
path: 'subdir',
files: [
{
type: 'file',
path: 'AnotherFile.cls',
content: 'public class AnotherClass{}',
},
],
},
{
type: 'directory',
path: 'subdir2',
files: [
{
type: 'file',
path: 'SomeFile2.cls',
content: 'public class MyClass{}',
},
{
type: 'directory',
path: 'subdir',
files: [
{
type: 'file',
path: 'AnotherFile2.cls',
content: 'public class AnotherClass{}',
},
],
},
],
},
],
},
]);

const result = await ApexFileReader.processFiles(fileSystem, '', false);
expect(result.length).toBe(4);
});
});
4 changes: 2 additions & 2 deletions src/application/apex-file-reader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ export class ApexFileReader {
const currentPath = fileSystem.joinPath(rootPath, filePath);
if (await fileSystem.isDirectory(currentPath)) {
paths.push(...(await this.getFilePaths(fileSystem, currentPath)));
return paths;
} else {
paths.push(currentPath);
}
paths.push(currentPath);
}
return paths;
}
Expand Down

0 comments on commit fa40111

Please sign in to comment.