File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed
Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import fs from 'fs'
44import yaml from 'js-yaml'
55import path from 'path'
66import ora from 'ora'
7+ import { execSync } from 'child_process'
78import { callModelsApi } from '@/ai-tools/lib/call-models-api'
89import dotenv from 'dotenv'
910dotenv . config ( { quiet : true } )
@@ -13,7 +14,18 @@ const promptDir = path.join(__dirname, '../prompts')
1314const promptTemplatePath = path . join ( promptDir , 'prompt-template.yml' )
1415
1516if ( ! process . env . GITHUB_TOKEN ) {
16- throw new Error ( 'Error! You must have a GITHUB_TOKEN set in an .env file to run this script.' )
17+ // Try to find a token via the CLI before throwing an error
18+ const token = execSync ( 'gh auth token' ) . toString ( )
19+ if ( token . startsWith ( 'gh' ) ) {
20+ process . env . GITHUB_TOKEN = token
21+ } else {
22+ console . warn ( `🔑 A token is needed to run this script. Please do one of the following and try again:
23+
24+ 1. Add a GITHUB_TOKEN to a local .env file.
25+ 2. Install https://cli.github.com and authenticate via 'gh auth login'.
26+ ` )
27+ process . exit ( 1 )
28+ }
1729}
1830
1931interface EditorType {
You can’t perform that action at this time.
0 commit comments