Puppet Function: wmflib::dir::split
- Defined in:
- modules/wmflib/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 20 21 |
# File 'modules/wmflib/functions/dir/split.pp', line 10
function wmflib::dir::split(
Variant[Stdlib::Unixpath, Array[Stdlib::Unixpath]] $dirs
) >> Array[Stdlib::Unixpath] {
[$dirs].flatten.unique.map |$dir| {
$dir.split('/').reduce([]) |$memo, $value| {
$value.empty ? {
true => $memo,
default => $memo + "${memo[-1]}/${value}",
}
}
}.flatten.unique
}
|