@@ -2,18 +2,23 @@ import { log } from "@/lib/handlers/log.ts";
22import { ApplicationNamespace , ConfigFilename } from "@/constants/application.ts" ;
33import { getDefaultConfig } from "@/lib/main/get-default-config.ts" ;
44import { initializeConfigFile } from "@/lib/main/initialize-config-file.ts" ;
5+ import { BaseDirectory , exists , readTextFile } from "@tauri-apps/plugin-fs" ;
56import { type ConfigType , ConfigValidator } from "@/types/config/config.schema.ts" ;
6- const { BaseDirectory, exists, readTextFile } = window . __TAURI__ . fs ;
77
88export async function getConfigFile ( ) : Promise < ConfigType > {
9- log . debug ( "Executing the 'before' method on extensions' hook for 'getConfigFile'" ) ;
10- const hookResponse = await window [ ApplicationNamespace ] . hooks . getConfigFile . before ( ) ;
9+ const hooksArray = window [ ApplicationNamespace ] . hooks . getConfigFile . before ;
1110
12- if ( hookResponse === "stop" ) {
13- log . debug ( "'getConfigFile.before' hook has aborted execution" ) ;
11+ log . debug ( "Starting iterating through hooks for 'getConfigFile.before'" ) ;
12+ for ( const [ hookIndex , hookFunction ] of hooksArray . entries ( ) ) {
13+ log . debug ( "Executing a hook with the next index:" , hookIndex . toString ( ) ) ;
14+ const hookResponse = await hookFunction ( ) ;
1415
15- // Awaiting here will just be an unnecessary action
16- return getDefaultConfig ( ) ;
16+ if ( hookResponse . status === "stop" ) {
17+ log . debug ( `A hook with the index of ${ hookIndex } has aborted execution` ) ;
18+
19+ // Awaiting here will just be an unnecessary action
20+ return hookResponse . response ;
21+ }
1722 }
1823
1924 log . debug ( "Checking if config file exists" ) ;
0 commit comments