MCPcopy Create free account
hub / github.com/dyoshikawa/rulesync / listDirectory

Method listDirectory

src/lib/github-client.ts:109–139  ·  view source on GitHub ↗

* List contents of a directory in a repository

(
    owner: string,
    repo: string,
    path: string,
    ref?: string,
  )

Source from the content-addressed store, hash-verified

107 * List contents of a directory in a repository
108 */
109 async listDirectory(
110 owner: string,
111 repo: string,
112 path: string,
113 ref?: string,
114 ): Promise<GitHubFileEntry[]> {
115 try {
116 const { data } = await this.octokit.repos.getContent({
117 owner,
118 repo,
119 path,
120 ref,
121 });
122
123 // API returns single object for files, array for directories
124 if (!Array.isArray(data)) {
125 throw new GitHubClientError(`Path "${path}" is not a directory`);
126 }
127
128 const entries: GitHubFileEntry[] = [];
129 for (const item of data) {
130 const parsed = GitHubFileEntrySchema.safeParse(item);
131 if (parsed.success) {
132 entries.push(parsed.data);
133 }
134 }
135 return entries;
136 } catch (error) {
137 throw this.handleError(error);
138 }
139 }
140
141 /**
142 * Get raw file content from a repository

Callers 4

listDirectoryRecursiveFunction · 0.45
discoverGithubSkillDirsFunction · 0.45
getCachedDirectoryFunction · 0.45

Calls 1

handleErrorMethod · 0.95

Tested by

no test coverage detected