From 555f0378b4266142a3a937ea47ce0d781ae16541 Mon Sep 17 00:00:00 2001 From: Florian Rappl Date: Tue, 4 Apr 2023 15:40:24 +0200 Subject: [PATCH] Improved code helpers --- src/ElectronNET.CLI/ProcessHelper.cs | 12 +++++++----- src/ElectronNET.Host/src/build-helper.ts | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/ElectronNET.CLI/ProcessHelper.cs b/src/ElectronNET.CLI/ProcessHelper.cs index 0cd5d0a..3cfe6d1 100644 --- a/src/ElectronNET.CLI/ProcessHelper.cs +++ b/src/ElectronNET.CLI/ProcessHelper.cs @@ -7,26 +7,28 @@ namespace ElectronNET.CLI { public class ProcessHelper { - public static void CheckNodeModules(string tempPath, bool force = false) + public static void CheckNodeModules(string root, bool force = false) { - var nodeModulesDirPath = Path.Combine(tempPath, "node_modules"); + var nodeModulesDirPath = Path.Combine(root, "node_modules"); if (!Directory.Exists(nodeModulesDirPath) || force) { Console.WriteLine("Starting npm install ..."); - ProcessHelper.CmdExecute("npm install", tempPath); + ProcessHelper.CmdExecute("npm install", root); } } - public static void BundleHostHook(string tempPath) + public static void BundleHostHook(string root) { var electronhosthookDir = Path.Combine(Directory.GetCurrentDirectory(), "ElectronHostHook"); if (Directory.Exists(electronhosthookDir)) { + CheckNodeModules(electronhosthookDir); + // TODO: should be more complex, i.e., look at package.json, determine "source" or "main" and resolve it var hookSource = Path.Combine(electronhosthookDir, "index.ts"); - var hookTarget = Path.Combine(tempPath, "dist", "host-hook.js"); + var hookTarget = Path.Combine(root, "dist", "host-hook.js"); Console.WriteLine("Bundle ElectronHostHook ..."); CmdExecute($"npm start --outfile={hookTarget}", electronhosthookDir); } diff --git a/src/ElectronNET.Host/src/build-helper.ts b/src/ElectronNET.Host/src/build-helper.ts index 2114a79..94e9f60 100644 --- a/src/ElectronNET.Host/src/build-helper.ts +++ b/src/ElectronNET.Host/src/build-helper.ts @@ -5,7 +5,7 @@ import { resolve } from "path"; const manifestFileName = process.argv[2]; const cwd = process.cwd(); -const manifestFilePath = resolve(cwd, ".bin", manifestFileName); +const manifestFilePath = resolve(cwd, "bin", manifestFileName); const manifestFile = require(manifestFilePath); const builderConfiguration = { ...manifestFile.build };