-
Notifications
You must be signed in to change notification settings - Fork 616
Added output configurations. Related to #3170 #3543
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice start! Do you think you can also make the necessary changes to the Processes
implementations?
/** Starts the process and returns a handle for interacting with it. | ||
* Closing the resource will kill the process if it has not already terminated. | ||
*/ | ||
final def spawn[F[_]: Processes]: Resource[F, Process[F]] = | ||
Processes[F].spawn(this) | ||
} | ||
|
||
sealed trait ProcessOutputMode | ||
object ProcessOutputMode { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These look like the right set of options! We need to support stdin
, stdout
, and stderr
to be configured separately.
I think this should do it but do let me know if there is more to improve on this |
} { process => | ||
F.delay(process.isAlive()) | ||
.ifM( | ||
evalOnVirtualThreadIfAvailable( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deleted by mistake?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Must've been deleted while solving merge conflicts adding them back
sealed trait StreamOutputMode | ||
object StreamOutputMode { | ||
case object Pipe extends StreamOutputMode | ||
case object Inherit extends StreamOutputMode | ||
case object Ignore extends StreamOutputMode | ||
case class FileOutput(path: Path) extends StreamOutputMode | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sealed trait StreamOutputMode | |
object StreamOutputMode { | |
case object Pipe extends StreamOutputMode | |
case object Inherit extends StreamOutputMode | |
case object Ignore extends StreamOutputMode | |
case class FileOutput(path: Path) extends StreamOutputMode | |
} | |
sealed abstract class StreamRedirect | |
object StreamRedirect { | |
case object Pipe extends StreamRedirect | |
case object Inherit extends StreamRedirect | |
case object Discard extends StreamRedirect | |
final case class File(path: Path) extends StreamRedirect | |
} |
env = | ||
|
||
|
||
val spawnOptions = js.Dynamic.literal { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of using js.Dynamic
can you update the SpawnOptions
face to add the additional fields?
/** @see [[outputMode]] */ | ||
def withOutputConfig(outputConfig: ProcessOutputConfig): ProcessBuilder |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think separating it out into three config methods for stdin/stdout/stderr (like the JDK process builder) will make the API easier to use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your work on this PR! Tests currently are not passing on JVM or JS. (Native is broken for reasons not related to you.)
@armanbilge The tests for rootJS are currently not passing for the merged option. Do you have an idea on how we can proceed with that. I'm thinking about setting the stdio to |
I think Node.js might not support that feature, so we can just implement it with FS2 |
Exposed a Configuration for the user to select how they want to deal with sterr and stdout for streams in /io/shared/src/main/scala/fs2/io/process/ProcessesBuilder.scala