-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
lib.rs
67 lines (61 loc) · 1.69 KB
/
lib.rs
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
58
59
60
61
62
63
64
65
66
67
#![feature(assert_matches)]
#![feature(box_patterns)]
#![feature(error_generic_member_access)]
#![feature(hash_extract_if)]
#![feature(option_get_or_insert_default)]
#![feature(once_cell_try)]
#![deny(clippy::all)]
// Clippy's needless mut lint is buggy: https://github.com/rust-lang/rust-clippy/issues/11299
#![allow(clippy::needless_pass_by_ref_mut)]
mod child;
mod cli;
mod commands;
mod config;
mod daemon;
mod engine;
mod execution_state;
mod framework;
pub(crate) mod globwatcher;
pub mod graph;
mod hash;
mod opts;
mod package_graph;
mod package_json;
mod package_manager;
mod process;
mod rewrite_json;
mod run;
mod shim;
mod task_graph;
mod task_hash;
mod tracing;
use anyhow::Result;
pub use child::spawn_child;
pub use crate::{cli::Args, execution_state::ExecutionState};
use crate::{commands::CommandBase, package_manager::PackageManager};
/// The payload from running main, if the program can complete without using Go
/// the Rust variant will be returned. If Go is needed then the execution state
/// that should be passed to Go will be returned.
pub enum Payload {
Rust(Result<i32>),
Go(Box<CommandBase>),
}
pub fn get_version() -> &'static str {
include_str!("../../../version.txt")
.split_once('\n')
.expect("Failed to read version from version.txt")
.0
// On windows we still have a trailing \r
.trim_end()
}
pub fn main() -> Payload {
match shim::run() {
Ok(payload) => payload,
Err(err) => {
// This raw print matches the Go behavior, once we no longer care
// about matching formatting we should remove this.
println!("Turbo error: {err}");
Payload::Rust(Err(err))
}
}
}