main: Fixed npm installed checks and fixed HSD install

This commit is contained in:
Nathan Woodburn 2023-06-13 23:57:10 +10:00
parent 752d20f369
commit 112b719d78
Signed by: nathanwoodburn
GPG Key ID: 203B000478AD0EF1

View File

@ -50,6 +50,9 @@ namespace FireWallet
UpdateTheme(); UpdateTheme();
if (await LoadNode() != true) this.Close(); if (await LoadNode() != true) this.Close();
if (this.Disposing || this.IsDisposed) return;
if (userSettings.ContainsKey("hide-splash")) if (userSettings.ContainsKey("hide-splash"))
{ {
if (userSettings["hide-splash"] == "false") if (userSettings["hide-splash"] == "false")
@ -1363,6 +1366,7 @@ namespace FireWallet
notifyForm.ShowDialog(); notifyForm.ShowDialog();
notifyForm.Dispose(); notifyForm.Dispose();
this.Close(); this.Close();
Thread.Sleep(1000);
return; return;
} }
@ -1384,36 +1388,47 @@ namespace FireWallet
notifyForm.ShowDialog(); notifyForm.ShowDialog();
notifyForm.Dispose(); notifyForm.Dispose();
this.Close(); this.Close();
Thread.Sleep(1000);
return; return;
} }
// Check if npm installed // Check if npm installed
testInstalled = new Process(); testInstalled = new Process();
testInstalled.StartInfo.FileName = "npm"; testInstalled.StartInfo.FileName = "cmd.exe";
testInstalled.StartInfo.Arguments = "-v"; testInstalled.StartInfo.Arguments = "npm -v";
testInstalled.StartInfo.RedirectStandardOutput = true; testInstalled.StartInfo.RedirectStandardOutput = true;
testInstalled.StartInfo.UseShellExecute = false; testInstalled.StartInfo.UseShellExecute = false;
testInstalled.StartInfo.CreateNoWindow = true; testInstalled.StartInfo.CreateNoWindow = false;
testInstalled.Start(); testInstalled.Start();
// Wait 3 seconds and then kill
Thread.Sleep(3000);
testInstalled.Kill();
outputInstalled = testInstalled.StandardOutput.ReadToEnd(); outputInstalled = testInstalled.StandardOutput.ReadToEnd();
testInstalled.WaitForExit(); testInstalled.WaitForExit();
if (Regex.IsMatch(outputInstalled, @"^\d+\.\d+\.\d+$"))
if (outputInstalled.Length < 3)
{ {
AddLog("NPM is not installed"); AddLog("NPM is not installed");
AddLog(outputInstalled);
NotifyForm notifyForm = new NotifyForm("NPM is not installed\nPlease install it to install HSD dependencies"); NotifyForm notifyForm = new NotifyForm("NPM is not installed\nPlease install it to install HSD dependencies");
notifyForm.ShowDialog(); notifyForm.ShowDialog();
notifyForm.Dispose(); notifyForm.Dispose();
this.Close(); this.Close();
Thread.Sleep(1000);
return; return;
} }
AddLog("Prerequisites installed");
ProcessStartInfo startInfo = new ProcessStartInfo(); ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = "git"; startInfo.FileName = "git";
startInfo.Arguments = $"clone {repositoryUrl} {destinationPath}"; startInfo.Arguments = $"clone {repositoryUrl} {destinationPath}";
if (repositoryUrl == "https://github.com/handshake-org/hsd.git")
{
startInfo.Arguments = $"clone --depth 1 --branch latest {repositoryUrl} {destinationPath}";
}
startInfo.RedirectStandardOutput = true; startInfo.RedirectStandardOutput = true;
startInfo.UseShellExecute = false; startInfo.UseShellExecute = false;
startInfo.CreateNoWindow = hideScreen; startInfo.CreateNoWindow = hideScreen;