Fix action output issue

This commit is contained in:
Jaex 2016-10-14 20:43:04 +03:00
parent bb0e546d61
commit d89dd984f4
2 changed files with 18 additions and 9 deletions

View file

@ -67,7 +67,7 @@ public string Run(string filePath)
try
{
string newFilePath = "";
string outputPath = "";
using (Process process = new Process())
{
@ -81,17 +81,21 @@ public string Run(string filePath)
{
if (!string.IsNullOrEmpty(OutputExtension))
{
newFilePath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(filePath), System.IO.Path.GetFileNameWithoutExtension(filePath));
outputPath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(filePath), System.IO.Path.GetFileNameWithoutExtension(filePath));
if (!OutputExtension.Contains("."))
{
OutputExtension = "." + OutputExtension;
}
newFilePath += OutputExtension;
outputPath += OutputExtension;
}
else
{
outputPath = filePath;
}
psi.Arguments = CodeMenuEntryActions.Parse(Args, filePath, newFilePath);
psi.Arguments = CodeMenuEntryActions.Parse(Args, filePath, outputPath);
}
if (HiddenWindow)
@ -108,9 +112,9 @@ public string Run(string filePath)
process.WaitForExit();
}
if (!string.IsNullOrEmpty(newFilePath) && File.Exists(newFilePath))
if (!string.IsNullOrEmpty(outputPath) && File.Exists(outputPath))
{
return newFilePath;
return outputPath;
}
return filePath;

View file

@ -40,11 +40,16 @@ public CodeMenuEntryActions(string value, string description) : base(value, desc
public static string Parse(string pattern, string inputPath, string outputPath)
{
string result = pattern.Replace(input.ToPrefixString(), '"' + inputPath + '"');
string result = pattern;
if (!string.IsNullOrEmpty(outputPath))
if (inputPath != null)
{
result.Replace(output.ToPrefixString(), '"' + outputPath + '"');
result = result.Replace(input.ToPrefixString(), '"' + inputPath + '"');
}
if (outputPath != null)
{
result = result.Replace(output.ToPrefixString(), '"' + outputPath + '"');
}
return result;