Skip to main content

Crate glob_parent

Crate glob_parent 

Source
Expand description

§glob-parent — the non-magic parent of a glob

Given a glob, return the deepest parent directory that contains no glob magic — exactly what file watchers and build tools need to know which directory to watch. A faithful Rust port of the glob-parent npm package (used by gulp, chokidar, and friends), bundling ports of is-glob and is-extglob. Zero dependencies and #![no_std].

use glob_parent::glob_parent;

assert_eq!(glob_parent("path/to/*.js"), "path/to");
assert_eq!(glob_parent("path/*/file.js"), "path");
assert_eq!(glob_parent("path/**/*.js"), "path");
assert_eq!(glob_parent("*.js"), ".");
assert_eq!(glob_parent("/path/to/file.js"), "/path/to");

Functions§

glob_parent
Extract the non-magic parent path from a glob.
glob_parent_with_options
Extract the non-magic parent path from a glob.
is_extglob
Whether s contains an extglob pattern such as @(…), !(…), or +(…) (the is-extglob npm package).
is_glob
Whether s looks like a glob (the strict check of the is-glob npm package).