-
Notifications
You must be signed in to change notification settings - Fork 2
/
Export-Image.ps1
31 lines (28 loc) · 1.13 KB
/
Export-Image.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
param(
[string[]]$libPath,
[string]$workflowPath=".\workflows",
[string]$bootstrapperPath="..\.bonsai\Bonsai.exe"
)
function Export-Svg([string[]]$libPath, [string]$svgFileName, [string]$workflowFile)
{
$bootstrapperArgs = @()
foreach ($path in $libPath) {
$bootstrapperArgs += "--lib"
$bootstrapperArgs += "$(Resolve-Path $path)"
}
$bootstrapperArgs += "--export-image"
$bootstrapperArgs += "$svgFileName"
$bootstrapperArgs += "$workflowFile"
Write-Verbose "$($bootstrapperPath) $($bootstrapperArgs)"
&$bootstrapperPath $bootstrapperArgs
}
Import-Module (Join-Path $PSScriptRoot "Export-Tools.psm1")
$sessionPath = $ExecutionContext.SessionState.Path
foreach ($workflowFile in Get-ChildItem -File -Recurse (Join-Path $workflowPath "*.bonsai")) {
$svgFileName = "$($workflowFile.BaseName).svg"
Write-Host "Exporting $($svgFileName)"
$svgFileDirectory = Split-Path -Parent $workflowFile.FullName
$svgFile = $sessionPath.GetUnresolvedProviderPathFromPSPath((Join-Path $svgFileDirectory $svgFileName))
Export-Svg $libPath $svgFileName $workflowFile
Convert-Svg $svgFile
}