1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//! Run other programs, such as `git`, `ffmpeg`, or a build script, and read what they wrote.
//!
//! [`run`] runs a command and waits for its [`ProcessResult`]. [`Process`] sets options first,
//! and [`Process::start`] returns a [`RunningProcess`] you can read from, signal, or stop while it
//! runs. [`fake`](fake()) replaces processes in tests. The
//! [processes guide](https://github.com/laravel/rust-framework/blob/0.x/docs/processes.md)
//! walks through each of these.
//!
//! A command is a list of arguments that Laravel passes to the program without a shell, so input
//! can't change what runs. When you need pipes or globs, [`Process::shell`] runs the command
//! through a shell instead. Processes start in the
//! application's base path, inherit its environment, and time out after 60 seconds.
//!
//! ```no_run
//! use laravel::process::{self, Process};
//! use laravel::time::ToSpan;
//!
//! # async fn example() -> laravel::Result<()> {
//! let status = process::run(["git", "status", "--porcelain"]).await?;
//! if status.output().is_empty() {
//! // ...
//! }
//!
//! Process::new(["bash", "import.sh"])
//! .timeout(2.minutes())
//! .env("IMPORT_PATH", "storage/imports")
//! .run()
//! .await?
//! .ensure_successful()?;
//! # Ok(())
//! # }
//! ```
//!
//! A run returns once the process exits. It doesn't wait for programs the process started in the
//! background, such as a server launched with `&`, and its result leaves out what they write
//! afterward. If you pass a whole command line as one argument, such as
//! `Process::new(["node report.js"])`, the process fails to start, and the error says to split the
//! arguments. Without an inherited `PATH`, Unix looks for the program in a short default list of
//! directories. A zero or negative timeout means no timeout.
//!
//! On Unix, each process leads its own process group. Signals, [`RunningProcess::stop`],
//! timeouts, and dropping the process reach the whole group, so they also stop the programs it
//! started. Pressing Ctrl+C signals the application but not the process, which stops when the
//! application drops it. When a process exits on its own, programs it started in the background
//! keep running, as does a program that moves to its own process group.
//!
//! Output without a line ending, such as a prompt or a progress bar redrawn with `\r`, reaches
//! [`Process::on_output`] and [`RunningProcess::chunks`] right away. A chunk can end mid-word, so
//! [`RunningProcess::wait_until`] can miss text split across two chunks. A started fake has already
//! finished when `start` returns.
pub use *;
pub use ;