Skip to content

Commit

Permalink
Enable ydoc-server tests (#12252)
Browse files Browse the repository at this point in the history
Enable `ydoc-server` tests after `corepack` is fixed in #12249
  • Loading branch information
4e6 authored Feb 12, 2025
1 parent cbd85a2 commit f815f49
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
1 change: 1 addition & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,7 @@ lazy val enso = (project in file("."))
`text-buffer`,
`version-output`,
`ydoc-polyfill`,
`ydoc-server`,
`zio-wrapper`
)
.settings(Global / concurrentRestrictions += Tags.exclusive(Exclusive))
Expand Down
31 changes: 24 additions & 7 deletions project/Ydoc.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ import scala.sys.process.*

object Ydoc {

private val corepackCommand =
if (Platform.isWindows) "corepack.cmd" else "corepack"

private val pnpmCommand =
if (Platform.isWindows) "corepack.cmd pnpm" else "corepack pnpm"
s"$corepackCommand pnpm"

/** Generates the bundled JS source of the Ydoc server.
*
Expand Down Expand Up @@ -53,10 +56,11 @@ object Ydoc {
ydocServerResourceManaged / "org" / "enso" / "ydoc" / "server" / "ydoc.cjs"

if (changed) {
val command = s"$pnpmCommand build:ydoc-server-polyglot"
streams.log.info(command)
val exitCode = command ! streams.log
runCommand(s"$corepackCommand --version", streams)
runCommand(s"$pnpmCommand --version", streams)

val command = s"$pnpmCommand build:ydoc-server-polyglot"
val exitCode = runCommand(command, streams)
if (exitCode != 0) {
throw new CommandFailed(command, exitCode)
}
Expand Down Expand Up @@ -87,9 +91,11 @@ object Ydoc {
case (changed, _) =>
val nodeModules = base / "node_modules"
if (changed || !nodeModules.isDirectory) {
val command = s"$pnpmCommand i --frozen-lockfile"
streams.log.info(command)
val exitCode = command ! streams.log
runCommand(s"$corepackCommand --version", streams)
runCommand(s"$pnpmCommand --version", streams)

val command = s"$pnpmCommand i --frozen-lockfile"
val exitCode = runCommand(command, streams)
if (exitCode != 0) {
throw new CommandFailed(command, exitCode)
}
Expand All @@ -101,6 +107,17 @@ object Ydoc {
generator(inputFile)
}

/** Run command printing the output to the log stream.
*
* @param command the command to run
* @param streams the build streams
* @return exit code
*/
private def runCommand(command: String, streams: TaskStreams): Int = {
streams.log.info(command)
command ! streams.log
}

final private class CommandFailed(command: String, exitCode: Int)
extends FeedbackProvidedException {

Expand Down

0 comments on commit f815f49

Please sign in to comment.