Skip to content

Commit d91d261

Browse files
junhoyeoclaude
andcommitted
[cli] Auto-detect fine-grained GitHub PATs by prefix
Tokens starting with 'github_pat_' are now automatically recognized as fine-grained personal access tokens, eliminating the need to use the --fg-token flag. The --fg-token flag is still supported for backwards compatibility, but users can now simply use --token or the GITHUB_TOKEN environment variable with fine-grained PATs. This enhancement improves the user experience by reducing the need to remember which flag to use based on the token type. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 9790345 commit d91d261

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/index.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,22 @@ const main = async () => {
4343

4444
zx.$.verbose = !!parsedOptions.verbose;
4545

46+
// Helper function to detect if a token is a fine-grained PAT
47+
const isFineGrainedToken = (token: string): boolean => {
48+
return token.startsWith('github_pat_');
49+
};
50+
4651
let githubToken: string = '';
4752
let isFineGrained: boolean = false;
4853
if (parsedOptions.token?.[0]) {
4954
[githubToken] = parsedOptions.token;
55+
isFineGrained = isFineGrainedToken(githubToken);
5056
} else if (parsedOptions.fgToken?.[0]) {
5157
[githubToken] = parsedOptions.fgToken;
5258
isFineGrained = true;
5359
} else {
5460
githubToken = process.env.GITHUB_TOKEN || '';
61+
isFineGrained = isFineGrainedToken(githubToken);
5562
}
5663

5764
let depth: number = 1;

0 commit comments

Comments
 (0)