KevinMarquette / PSGraph

A set of utilities for working with Graphviz in Powershell
MIT License
204 stars 49 forks source link

Detect graphViz outside of -GraphVizPath #88

Open endowdly opened 5 years ago

endowdly commented 5 years ago

We have:

    $GraphVizPath = (
            'C:\Program Files\NuGet\Packages\Graphviz*\dot.exe',
            'C:\program files*\GraphViz*\bin\dot.exe',
            '/usr/local/bin/dot'
        ),

…which of course we can change.

Why not something like...

$isGraphviz = 
    try { 
        Get-Command dot -CommandType Application -ErrorAction Stop > $null
        $true
    catch {
        $false
    }

if (-not $isGraphviz) {
    $graphViz =
        Resolve-Path -Path $GraphVizPath -ErrorAction SilentlyContinue |
        Get-Item |
        Where-Object BaseName -eq 'dot' |   # PS -- don't need quotes here
        Select-Object -First 1
}

...so dot's path can be snagged straight from my env:\path without having to enter it in manually every time? :)

KevinMarquette commented 5 years ago

That's a good idea.

endowdly commented 5 years ago

fwiw: to get dot's path, I currently use:

<# … #> -GraphVizPath (Get-Command dot).Source