Skip to content

Commit 7d5fce7

Browse files
Copilotretsohuang
andcommitted
docs: improve FsLike interface documentation and fix main() call
- Add documentation explaining why FsLike combines sync and async methods - Make prepareReview call in main() explicit with all parameters - Bind sync methods to nodeFs to avoid context issues Co-authored-by: retsohuang <785920+retsohuang@users.noreply.github.com>
1 parent 29838ab commit 7d5fce7

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

  • plugins/code-review-tools/scripts/src

plugins/code-review-tools/scripts/src/cli.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ import {
1717

1818
const DEFAULT_DIR = process.cwd()
1919

20+
// FsLike combines isomorphic-git's PromiseFsClient (async) with common sync methods
21+
// This hybrid approach is needed because:
22+
// - isomorphic-git requires PromiseFsClient for git operations
23+
// - Sync methods are used for convenience in config loading and file checks
2024
interface FsLike extends PromiseFsClient {
2125
existsSync(path: string): boolean
2226
readFileSync(path: string, encoding: BufferEncoding): string
@@ -26,10 +30,10 @@ interface FsLike extends PromiseFsClient {
2630

2731
const defaultFs: FsLike = {
2832
promises: nodeFs.promises,
29-
existsSync: nodeFs.existsSync,
30-
readFileSync: nodeFs.readFileSync,
31-
writeFileSync: nodeFs.writeFileSync,
32-
mkdirSync: nodeFs.mkdirSync,
33+
existsSync: nodeFs.existsSync.bind(nodeFs),
34+
readFileSync: nodeFs.readFileSync.bind(nodeFs),
35+
writeFileSync: nodeFs.writeFileSync.bind(nodeFs),
36+
mkdirSync: nodeFs.mkdirSync.bind(nodeFs),
3337
} as FsLike
3438

3539
interface SuccessOutput<T = unknown> {
@@ -393,6 +397,9 @@ async function main(): Promise<void> {
393397
const result = await prepareReview(
394398
parsedArgs.positional as string,
395399
parsedArgs.pluginRoot as string,
400+
DEFAULT_DIR,
401+
defaultFs,
402+
defaultFs,
396403
)
397404

398405
if (!result.success) {

0 commit comments

Comments
 (0)