Rework message output for ExecCommand()

This commit is contained in:
Yorick Barbanneau 2018-04-12 00:57:00 +02:00
parent 10eecf17f5
commit 5e9148b111

View file

@ -589,20 +589,20 @@ function ExecCommand {
) )
$path = $params.path.Replace("##mod_path##", $script:current_module_path) $path = $params.path.Replace("##mod_path##", $script:current_module_path)
$args = $params.arguments.Replace("##mod_path##", $script:current_module_path) $args = $params.arguments.Replace("##mod_path##", $script:current_module_path)
Write-Host -NoNewline "`tExecute : $path : " Write-Host "`n`tExecute $path : "
$path = Invoke-Expression """$($path)""" $path = Invoke-Expression """$($path)"""
if ( -not ((Test-Path $path) -or $path -eq "powershell") ) { if ( -not ((Test-Path $path) -or $path -eq "powershell") ) {
Write-Host -ForegroundColor Yellow "File not found" Write-Host -ForegroundColor Yellow "`t`tFile not found"
return return
} }
try { try {
Start-Process -NoNewWindow -wait -filepath $path -ArgumentList $args Start-Process -NoNewWindow -wait -filepath $path -ArgumentList $args -ErrorAction Stop
Write-Host -ForegroundColor Green "`t`tExecution done"
} }
catch { catch {
Write-Host -NoNewLine -ForegroundColor Red "Error`n`t" Write-Host -NoNewLine -ForegroundColor Red "`tError`n`t`t"
Write-Host -ForegroundColor DarkRed $Error[0].Exception.Message Write-Host -ForegroundColor DarkRed $Error[0].Exception.Message
} }
Write-Host "`n"
} }
function ProcessModuleFile { function ProcessModuleFile {
@ -626,7 +626,7 @@ function ProcessModuleFile {
$mod.actions | Foreach { $mod.actions | Foreach {
$action_file = "" $action_file = ""
$current_action = @{} $current_action = @{}
$script:current_module_path = $(Get-ChildItem $path).DirectoryName + "\" + $(Get-ChildItem $path).BaseName + '\' $script:current_module_path = $(Get-ChildItem $path).DirectoryName + "\" + $(Get-ChildItem $path).BaseName + '\'
foreach( $p in $_.psobject.properties.name ){ foreach( $p in $_.psobject.properties.name ){
$current_action[$p] = $_.$p $current_action[$p] = $_.$p