turbopack_node/debug.rs
1use std::env;
2
3const DEBUG_JS_VAR: &str = "TURBOPACK_DEBUG_JS";
4
5/// Checks if the operation passed is included in the `TURBOPACK_DEBUG_JS` env
6/// var to enable node.js debugging at runtime.
7///
8/// This is preferable to manually passing a boolean because recompiling won't
9/// be necessary.
10pub fn should_debug(operation: &str) -> bool {
11 // TODO(sokra) It's not persistent caching safe to read an env var this way.
12 // This must use turbo_tasks_env instead.
13 let Ok(val) = env::var(DEBUG_JS_VAR) else {
14 return false;
15 };
16
17 val == "*" || val.split(',').any(|part| part == operation)
18}