Skip to content
Snippets Groups Projects
Commit 61d8aca2 authored by michael.minelli's avatar michael.minelli
Browse files

ExerciseDockerCompose => Add rejectIfCodeIsNotZero argument

parent 31cd9b7a
No related branches found
No related tags found
No related merge requests found
...@@ -48,7 +48,7 @@ class ExerciseDockerCompose { ...@@ -48,7 +48,7 @@ class ExerciseDockerCompose {
this.events.emit('finished', success, code); this.events.emit('finished', success, code);
} }
private registerChildProcess(childProcess: ChildProcessWithoutNullStreams, resolve: (value: (number | PromiseLike<number>)) => void, reject: (reason?: unknown) => void, displayable: boolean) { private registerChildProcess(childProcess: ChildProcessWithoutNullStreams, resolve: (value: (number | PromiseLike<number>)) => void, reject: (reason?: unknown) => void, displayable: boolean, rejectIfCodeIsNotZero: boolean) {
childProcess.stdout.on('data', (data) => { childProcess.stdout.on('data', (data) => {
this.log(data.toString(), false, displayable); this.log(data.toString(), false, displayable);
}); });
...@@ -58,7 +58,7 @@ class ExerciseDockerCompose { ...@@ -58,7 +58,7 @@ class ExerciseDockerCompose {
}); });
childProcess.on('exit', (code) => { childProcess.on('exit', (code) => {
code !== null ? resolve(code) : reject(); code === null || (rejectIfCodeIsNotZero && code !== 0) ? reject(code) : resolve(code);
}); });
} }
...@@ -86,7 +86,7 @@ class ExerciseDockerCompose { ...@@ -86,7 +86,7 @@ class ExerciseDockerCompose {
} }
}); });
this.registerChildProcess(dockerCompose, resolve, reject, true); this.registerChildProcess(dockerCompose, resolve, reject, true, false);
}); });
} catch ( error ) { } catch ( error ) {
this.endStep(`Error while running the docker compose file`, true); this.endStep(`Error while running the docker compose file`, true);
...@@ -110,7 +110,7 @@ class ExerciseDockerCompose { ...@@ -110,7 +110,7 @@ class ExerciseDockerCompose {
shell: true shell: true
}); });
this.registerChildProcess(dockerCompose, resolve, reject, false); this.registerChildProcess(dockerCompose, resolve, reject, false, true);
}); });
} catch ( error ) { } catch ( error ) {
this.endStep(`Error while getting the linked services logs`, true); this.endStep(`Error while getting the linked services logs`, true);
...@@ -135,10 +135,10 @@ class ExerciseDockerCompose { ...@@ -135,10 +135,10 @@ class ExerciseDockerCompose {
shell: true shell: true
}); });
this.registerChildProcess(dockerCompose, resolve, reject, false); this.registerChildProcess(dockerCompose, resolve, reject, false, true);
}); });
} catch ( error ) { } catch ( error ) {
this.endStep(`Error stop and remove containers`, true); this.endStep(`Error while stopping and removing containers`, true);
this.finished(false, ExerciseCheckerError.DOCKER_COMPOSE_DOWN_ERROR); this.finished(false, ExerciseCheckerError.DOCKER_COMPOSE_DOWN_ERROR);
return; return;
} }
...@@ -161,7 +161,7 @@ class ExerciseDockerCompose { ...@@ -161,7 +161,7 @@ class ExerciseDockerCompose {
shell: true shell: true
}); });
this.registerChildProcess(dockerCompose, resolve, reject, false); this.registerChildProcess(dockerCompose, resolve, reject, false, true);
}); });
} catch ( error ) { } catch ( error ) {
this.endStep(`Error while removing dangling images`, true); this.endStep(`Error while removing dangling images`, true);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment