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

Expose pathToInput for any inputKind #19

Merged
merged 1 commit into from
Jan 22, 2022
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,8 @@ final class TestKit(jsEnv: JSEnv, timeout: FiniteDuration,
}

/** Converts a Path to an Input based on this Kit's defaultInputKind */
def pathToInput(path: Path): Input = {
import TestKit.InputKind._

defaultInputKind match {
case Script => Input.Script(path)
case CommonJSModule => Input.CommonJSModule(path)
case ESModule => Input.ESModule(path)
}
}
def pathToInput(path: Path): Input =
TestKit.pathToInput(path, defaultInputKind)

private def io[T <: JSRun](config: RunConfig)(start: RunConfig => T): (T, IOReader, IOReader) = {
val out = new IOReader
Expand Down Expand Up @@ -174,6 +167,17 @@ object TestKit {
private val completer =
ExecutionContext.fromExecutor(Executors.newSingleThreadExecutor())

/** Converts a Path to an Input based on the inputKind. */
def pathToInput(path: Path, inputKind: InputKind): Input = {
import InputKind._

inputKind match {
case Script => Input.Script(path)
case CommonJSModule => Input.CommonJSModule(path)
case ESModule => Input.ESModule(path)
}
}

sealed trait InputKind

object InputKind {
Expand Down