File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed
npm-packages/cli/source/lib Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -26,10 +26,15 @@ export function getToken() {
2626 const configDir = path . join ( os . homedir ( ) , '.pulse-editor' ) ;
2727 const configFile = path . join ( configDir , 'config.json' ) ;
2828 if ( fs . existsSync ( configFile ) ) {
29- const config = JSON . parse ( fs . readFileSync ( configFile , 'utf8' ) ) ;
30- if ( config . accessToken ) {
31- return config . accessToken as string ;
32- }
29+ try {
30+ const config = JSON . parse ( fs . readFileSync ( configFile , 'utf8' ) ) ;
31+ if ( config . accessToken ) {
32+ return config . accessToken as string ;
33+ }
34+ } catch ( error ) {
35+ console . error ( 'Failed to parse config.json:' , error ) ;
36+ // Return undefined if JSON parsing fails
37+ return undefined ;
3338 }
3439
3540 // If not found, return undefined
You can’t perform that action at this time.
0 commit comments