-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathTruffleCompiler.cs
More file actions
45 lines (39 loc) · 1.29 KB
/
TruffleCompiler.cs
File metadata and controls
45 lines (39 loc) · 1.29 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
namespace Solidoc
{
public static class TruffleCompiler
{
private static void Run(string workingDirectory, string filename, string arguments)
{
Console.WriteLine($"{filename} {arguments}");
var process = new Process
{
StartInfo = new ProcessStartInfo
{
FileName = filename,
WorkingDirectory = workingDirectory,
Arguments = arguments,
RedirectStandardOutput = true,
UseShellExecute = false,
CreateNoWindow = false
}
};
process.Start();
string result = process.StandardOutput.ReadToEnd();
process.WaitForExit();
Console.WriteLine(result);
}
public static void Compile(string workingDirectory)
{
bool isWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
if (isWindows)
{
Run(workingDirectory, "powershell.exe", "-c \"truffle compile\"");
return;
}
Run(workingDirectory, "/bin/bash", "-c \"truffle compile\"");
}
}
}