mirror of
https://github.com/ElectronNET/Electron.NET.git
synced 2026-07-17 22:26:00 +00:00
cleanup - remove old install
This commit is contained in:
@@ -1,65 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ElectronNET.CLI.Commands
|
||||
{
|
||||
public class InstallElectronCommand : ICommand
|
||||
{
|
||||
public const string COMMAND_NAME = "install";
|
||||
public const string COMMAND_DESCRIPTION = "install";
|
||||
public static IList<CommandOption> CommandOptions { get; set; } = new List<CommandOption>();
|
||||
|
||||
private string[] _args;
|
||||
|
||||
public InstallElectronCommand(string[] args)
|
||||
{
|
||||
_args = args;
|
||||
}
|
||||
|
||||
public Task<bool> ExecuteAsync()
|
||||
{
|
||||
return Task.Run(() =>
|
||||
{
|
||||
Console.WriteLine("Install Electron Host...");
|
||||
|
||||
string currentPath = Directory.GetCurrentDirectory();
|
||||
string targetPath = Path.Combine(currentPath, "..", "CLIDeploy");
|
||||
|
||||
Console.WriteLine("Target: " + targetPath);
|
||||
|
||||
if (Directory.Exists(targetPath) == false)
|
||||
{
|
||||
Directory.CreateDirectory(targetPath);
|
||||
}
|
||||
|
||||
EmbeddedFileHelper.DeployEmbeddedFile(targetPath, "main.js");
|
||||
EmbeddedFileHelper.DeployEmbeddedFile(targetPath, "package.json");
|
||||
EmbeddedFileHelper.DeployEmbeddedFile(targetPath, "package-lock.json");
|
||||
|
||||
Console.WriteLine("Start npm install...");
|
||||
using (Process cmd = new Process())
|
||||
{
|
||||
cmd.StartInfo.FileName = "cmd.exe";
|
||||
cmd.StartInfo.RedirectStandardInput = true;
|
||||
cmd.StartInfo.RedirectStandardOutput = true;
|
||||
cmd.StartInfo.CreateNoWindow = true;
|
||||
cmd.StartInfo.UseShellExecute = false;
|
||||
cmd.StartInfo.WorkingDirectory = targetPath;
|
||||
|
||||
cmd.Start();
|
||||
|
||||
cmd.StandardInput.WriteLine("npm install");
|
||||
cmd.StandardInput.Flush();
|
||||
cmd.StandardInput.Close();
|
||||
cmd.WaitForExit();
|
||||
Console.WriteLine(cmd.StandardOutput.ReadToEnd());
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user