Puppet Function: extlib::dir_split
- Defined in:
- functions/dir_split.pp
- Function type:
- Puppet Language
Summary
Splits the given directory or directories into individual paths.Overview
Use this function when you need to split a absolute path into multiple absolute paths that all descend from the given path.
10 11 12 13 14 15 16 17 18 19 |
# File 'functions/dir_split.pp', line 10
function extlib::dir_split(Variant[Stdlib::Absolutepath, Array[Stdlib::Absolutepath]] *$dirs) >> Array[String] {
[$dirs].flatten.unique.map | Stdlib::Absolutepath $dir | {
extlib::dir_clean($dir).split('/').reduce([]) |Array $memo, $value | {
empty($value) ? {
true => $memo,
default => $memo + "${memo[-1]}/${value}",
}
}
}.flatten.unique
}
|