1
1
mirror of https://github.com/theoludwig/programming-challenges.git synced 2025-05-18 12:02:53 +02:00

refactor: no duplicate of package.json in solutions

This commit is contained in:
Divlo
2021-12-06 19:04:16 +01:00
parent cffaa9ec40
commit 938702c23f
13 changed files with 42 additions and 31 deletions

View File

@ -3,6 +3,7 @@ import ora from 'ora'
class Docker {
static CONTAINER_TAG = 'programming-challenges'
static SIGSEGV_EXIT_CODE = 139
public async build (): Promise<void> {
const loader = ora('Building the Docker image').start()
@ -22,11 +23,18 @@ class Docker {
input
}
)
const { stdout, stderr } = await subprocess
if (stderr.length !== 0) {
throw new Error(stderr)
try {
const { stdout, stderr } = await subprocess
if (stderr.length !== 0) {
throw new Error(stderr)
}
return stdout
} catch (error: any) {
if (error.exitCode === Docker.SIGSEGV_EXIT_CODE) {
throw new Error('Docker run failed: SIGSEGV indicates a segmentation fault (attempts to access a memory location that it\'s not allowed to access).')
}
throw new Error(`Docker run failed: ${error.message as string}`)
}
return stdout
}
}