Skip to content

Commit

Permalink
fix: alias the BuilderUtils functions on PactBuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
rholshausen committed Dec 15, 2022
1 parent 042c3ff commit a21d7cd
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ import java.nio.file.Paths
import kotlin.io.path.exists

object BuilderUtils {
/**
* Loads the file given by the file path and returns the contents. Relative paths will be resolved against the
* current working directory.
*/
@JvmStatic
fun textFile(filePath: String): String {
var path = Paths.get(filePath)
Expand All @@ -15,6 +19,9 @@ object BuilderUtils {
return path.toFile().bufferedReader().readText()
}

/**
* Resolves the given file path. Relative paths will be resolved against the current working directory.
*/
@JvmStatic
fun filePath(filePath: String): String {
var path = Paths.get(filePath).toAbsolutePath()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ import io.pact.plugins.jvm.core.PactPlugin
import io.pact.plugins.jvm.core.PactPluginEntryNotFoundException
import io.pact.plugins.jvm.core.PactPluginNotFoundException
import mu.KLogging
import java.nio.file.Path
import java.nio.file.Paths
import kotlin.io.path.exists

interface DslBuilder {
fun addPluginConfiguration(matcher: ContentMatcher, pactConfiguration: Map<String, JsonValue>)
Expand Down Expand Up @@ -415,6 +418,19 @@ open class PactBuilder(
else -> listOf(MessageContents(OptionalBody.body(contents.toString().toByteArray())) to InteractionMarkup())
}
}

/**
* Loads the file given by the file path and returns the contents. Relative paths will be resolved against the
* current working directory.
*/
@JvmStatic
fun textFile(filePath: String) = BuilderUtils.textFile(filePath)

/**
* Resolves the given file path. Relative paths will be resolved against the current working directory.
*/
@JvmStatic
fun filePath(filePath: String) = BuilderUtils.filePath(filePath)
}
}

Expand Down

0 comments on commit a21d7cd

Please sign in to comment.