changed split to dirname and fixed syntax error in err message

This commit is contained in:
Nikola Jokic
2022-06-03 15:10:14 +02:00
parent 5ec2edbe11
commit b0cf60b678

View File

@@ -7,6 +7,7 @@ import {
ServiceContainerInfo, ServiceContainerInfo,
StepContainerInfo StepContainerInfo
} from 'hooklib/lib' } from 'hooklib/lib'
import * as path from 'path'
import { env } from 'process' import { env } from 'process'
import { v4 as uuidv4 } from 'uuid' import { v4 as uuidv4 } from 'uuid'
import { runDockerCommand, RunDockerCommandOptions } from '../utils' import { runDockerCommand, RunDockerCommandOptions } from '../utils'
@@ -146,7 +147,7 @@ export async function containerBuild(
tag: string tag: string
): Promise<void> { ): Promise<void> {
if (!args.dockerfile) { if (!args.dockerfile) {
throw new Error('Container build expects 'args.dockerfile' to be set') throw new Error("Container build expects 'args.dockerfile' to be set")
} }
const dockerArgs: string[] = ['build'] const dockerArgs: string[] = ['build']
@@ -160,9 +161,7 @@ export async function containerBuild(
} }
function getBuildContext(dockerfilePath: string): string { function getBuildContext(dockerfilePath: string): string {
const pathSplit = dockerfilePath.split('/') return path.dirname(dockerfilePath)
pathSplit.splice(pathSplit.length - 1)
return pathSplit.join('/')
} }
function getWorkingDir(dockerfilePath: string): string { function getWorkingDir(dockerfilePath: string): string {