Skip to content

Commit

Permalink
Merge pull request #2451 from maciej-izak/addOnStarted-p-param
Browse files Browse the repository at this point in the history
Pass instance of Diagnostics.Process for addOnStarted
  • Loading branch information
matthid authored Jan 16, 2020
2 parents 9770ecc + a780d51 commit 48f0c8b
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/app/Fake.Core.Process/CreateProcess.fs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ type CreateProcess<'TRes> =
member x.WorkingDirectory = x.InternalWorkingDirectory
member x.Environment = x.InternalEnvironment

/// Some information regaring the started process
type StartedProcessInfo =
internal {
InternalProcess : Process
}
member x.Process = x.InternalProcess

/// Module for creating and modifying CreateProcess<'TRes> instances.
/// You can manage:
Expand Down Expand Up @@ -333,14 +339,24 @@ module CreateProcess =
(fun state p -> ())
(fun prev state exitCode -> prev)
(fun _ -> f ())
/// Execute the given function right after the process is started.
/// Execute the given function right after the process is started.
let addOnStarted f (c:CreateProcess<_>) =
c
|> appendSimpleFuncs
ignore
(fun state p -> f ())
(fun prev state exitCode -> prev)
ignore

/// Execute the given function right after the process is started.
/// PID for process can be obtained from p parameter (p.Process.Id).
let addOnStartedEx (f:StartedProcessInfo -> _) (c:CreateProcess<_>) =
c
|> appendSimpleFuncs
ignore
(fun state p -> f { InternalProcess = p })
(fun prev state exitCode -> prev)
ignore

/// Sets the given environment variables
let withEnvironment (env: (string * string) list) (c:CreateProcess<_>)=
Expand Down

0 comments on commit 48f0c8b

Please sign in to comment.