Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add new error type and exit when needed #487

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/controller/StateController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export class StateController implements IOBserver{
if (event === EventType.Finish) {
await this.transitionToNextState();
} else {
if (event === EventType.UnknownError) {
if (event === EventType.UnknownError || event === EventType.UnresolvableError) {
await new CleanUpState().onStart();
process.exit(1);
} else {
Expand Down
4 changes: 4 additions & 0 deletions src/state/InitState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ export class InitState implements IState{
// Check if docker is running and it's the correct version
const isCorrectDockerComposeVersion = await this.dockerService.isCorrectDockerComposeVersion();
const isDockerStarted = await this.dockerService.checkDocker();
if (!(isCorrectDockerComposeVersion && isDockerStarted)) {
this.observer!.update(EventType.UnresolvableError);
return;
}
await this.dockerService.isPortInUse(NECESSARY_PORTS.concat(OPTIONAL_PORTS));

this.logger.info(`Setting configuration for ${this.cliOptions.network} network with latest images on host ${this.cliOptions.host} with dev mode turned ${this.cliOptions.devMode ? 'on' : 'off'} using ${this.cliOptions.fullMode? 'full': 'turbo'} mode in ${this.cliOptions.multiNode? 'multi' : 'single'} node configuration...`, this.stateName);
Expand Down
3 changes: 2 additions & 1 deletion src/types/EventType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@
export enum EventType{
Finish,
DockerError,
UnknownError
UnknownError,
UnresolvableError
}