mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-02-28 06:22:45 -08:00
refactor: extract config generation startup flow
This commit is contained in:
26
src/core/services/config-generation-runtime-service.ts
Normal file
26
src/core/services/config-generation-runtime-service.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { CliArgs } from "../../cli/args";
|
||||
|
||||
export interface ConfigGenerationRuntimeDeps {
|
||||
shouldStartApp: (args: CliArgs) => boolean;
|
||||
generateConfig: (args: CliArgs) => Promise<number>;
|
||||
onSuccess: (exitCode: number) => void;
|
||||
onError: (error: Error) => void;
|
||||
}
|
||||
|
||||
export function runGenerateConfigFlowRuntimeService(
|
||||
args: CliArgs,
|
||||
deps: ConfigGenerationRuntimeDeps,
|
||||
): boolean {
|
||||
if (!args.generateConfig || deps.shouldStartApp(args)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
deps.generateConfig(args)
|
||||
.then((exitCode) => {
|
||||
deps.onSuccess(exitCode);
|
||||
})
|
||||
.catch((error: Error) => {
|
||||
deps.onError(error);
|
||||
});
|
||||
return true;
|
||||
}
|
||||
Reference in New Issue
Block a user