Crate bazel_cwd

Crate bazel_cwd 

Source
Expand description

Resolve paths in a Bazel-aware manner

The bazel run command runs the specified executable with the working directory set to the runfiles tree of the binary, not the location where bazel run was run from. See https://bazel.build/docs/user-manual#running-executables for more.

This crates provides a BazelPath helper trait with an unbazelify function to resolve paths relative to wherever bazel run was run from, allowing for path parsing in a more user-friendly way.

use std::path::Path;
use bazel_cwd::BazelPath;

let path = Path::new("foo/bar");
let resolved_path = path.unbazelify().unwrap();
// resolved_path will be an absolute path, resolving the relative path against the directory
// `bazel run` was run in.

Traitsยง

BazelPath