Last active
March 5, 2021 18:28
-
-
Save sowderca/21c6962ab111a22ac7cef07a0fc9e9c2 to your computer and use it in GitHub Desktop.
flat directory file dependency solution
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env pwsh | |
#Requires -Version 7 | |
param([string] $path); | |
Push-Location -Path $path; | |
function order([string] $Path) { | |
[Collections.Stack] $stack = [Collections.Stack]::new(); | |
foreach ($file in (Get-ChildItem -Path $Path -Filter '*.txt')) { | |
[void] $stack.Push($file.Name); | |
$file | Get-Content | ForEach-Object { | |
[string]::IsNullOrEmpty($_) ? (&{return}) : (order($_)); | |
} | |
} | |
return $stack.ToArray(); | |
} | |
order -Path $path | Select-Object -Unique; | |
Pop-Location; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment