Skip to content

Commit f709f65

Browse files
committed
always invoke npm install
1 parent 71d2b88 commit f709f65

File tree

3 files changed

+25
-34
lines changed

3 files changed

+25
-34
lines changed

ElectronNET.CLI/Commands/AddCommand.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ public Task<bool> ExecuteAsync()
6868
EmbeddedFileHelper.DeployEmbeddedFile(targetFilePath, "package.json", "ElectronHostHook.");
6969
EmbeddedFileHelper.DeployEmbeddedFile(targetFilePath, "tsconfig.json", "ElectronHostHook.");
7070

71+
// npm for typescript compiler etc.
72+
Console.WriteLine("Start npm install...");
73+
ProcessHelper.CmdExecute("npm install", targetFilePath);
74+
7175
// search .csproj
7276
Console.WriteLine($"Search your .csproj to add configure CopyToPublishDirectory to 'Never'");
7377
var projectFile = Directory.EnumerateFiles(currentDirectory, "*.csproj", SearchOption.TopDirectoryOnly).FirstOrDefault();

ElectronNET.CLI/Commands/BuildCommand.cs

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class BuildCommand : ICommand
1616
public static string COMMAND_ARGUMENTS = "Needed: '/target' with params 'win/osx/linux' to build for a typical app or use 'custom' and specify .NET Core build config & electron build config" + Environment.NewLine +
1717
" for custom target, check .NET Core RID Catalog and Electron build target/" + Environment.NewLine +
1818
" e.g. '/target win' or '/target custom \"win7-x86;win32\"'" + Environment.NewLine +
19-
"Optional: '/dotnet-configuration' with the desired .NET Core build config e.g. release or debug. Default = Release" + Environment.NewLine +
19+
"Optional: '/dotnet-configuration' with the desired .NET Core build config e.g. release or debug. Default = Release" + Environment.NewLine +
2020
"Optional: '/electron-arch' to specify the resulting electron processor architecture (e.g. ia86 for x86 builds). Be aware to use the '/target custom' param as well!" + Environment.NewLine +
2121
"Optional: '/electron-params' specify any other valid parameter, which will be routed to the electron-packager." + Environment.NewLine +
2222
"Full example for a 32bit debug build with electron prune: build /target custom win7-x86;win32 /dotnet-configuration Debug /electron-arch ia32 /electron-params \"--prune=true \"";
@@ -86,32 +86,26 @@ public Task<bool> ExecuteAsync()
8686

8787
DeployEmbeddedElectronFiles.Do(tempPath);
8888

89-
var checkForNodeModulesDirPath = Path.Combine(tempPath, "node_modules");
89+
var nodeModulesDirPath = Path.Combine(tempPath, "node_modules");
9090

91-
if (Directory.Exists(checkForNodeModulesDirPath) == false)
91+
92+
Console.WriteLine("node_modules missing in: " + checkForNodeModulesDirPath);
93+
94+
Console.WriteLine("Start npm install...");
95+
ProcessHelper.CmdExecute("npm install", tempPath);
96+
97+
Console.WriteLine("Start npm install electron-packager...");
98+
99+
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
92100
{
93-
Console.WriteLine("node_modules missing in: " + checkForNodeModulesDirPath);
94-
95-
Console.WriteLine("Start npm install...");
96-
ProcessHelper.CmdExecute("npm install", tempPath);
97-
98-
Console.WriteLine("Start npm install electron-packager...");
99-
100-
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
101-
{
102-
// Works proper on Windows...
103-
ProcessHelper.CmdExecute("npm install electron-packager --global", tempPath);
104-
}
105-
else
106-
{
107-
// ToDo: find another solution or document it proper
108-
// GH Issue https://github.com/electron-userland/electron-prebuilt/issues/48
109-
Console.WriteLine("Electron Packager - make sure you invoke 'sudo npm install electron-packager --global' at " + tempPath + " manually. Sry.");
110-
}
101+
// Works proper on Windows...
102+
ProcessHelper.CmdExecute("npm install electron-packager --global", tempPath);
111103
}
112104
else
113105
{
114-
Console.WriteLine("Skip npm install, because node_modules directory exists in: " + checkForNodeModulesDirPath);
106+
// ToDo: find another solution or document it proper
107+
// GH Issue https://github.com/electron-userland/electron-prebuilt/issues/48
108+
Console.WriteLine("Electron Packager - make sure you invoke 'sudo npm install electron-packager --global' at " + tempPath + " manually. Sry.");
115109
}
116110

117111
Console.WriteLine("ElectronHostHook handling started...");

ElectronNET.CLI/Commands/StartElectronCommand.cs

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,19 +61,12 @@ public Task<bool> ExecuteAsync()
6161

6262
DeployEmbeddedElectronFiles.Do(tempPath);
6363

64-
var checkForNodeModulesDirPath = Path.Combine(tempPath, "node_modules");
64+
var nodeModulesDirPath = Path.Combine(tempPath, "node_modules");
6565

66-
if (Directory.Exists(checkForNodeModulesDirPath) == false)
67-
{
68-
Console.WriteLine("node_modules missing in: " + checkForNodeModulesDirPath);
66+
Console.WriteLine("node_modules missing in: " + nodeModulesDirPath);
6967

70-
Console.WriteLine("Start npm install...");
71-
ProcessHelper.CmdExecute("npm install", tempPath);
72-
}
73-
else
74-
{
75-
Console.WriteLine("Skip npm install, because node_modules directory exists in: " + checkForNodeModulesDirPath);
76-
}
68+
Console.WriteLine("Start npm install...");
69+
ProcessHelper.CmdExecute("npm install", tempPath);
7770

7871
Console.WriteLine("ElectronHostHook handling started...");
7972

@@ -111,6 +104,6 @@ public Task<bool> ExecuteAsync()
111104
});
112105
}
113106

114-
107+
115108
}
116109
}

0 commit comments

Comments
 (0)