Skip to content

Commit

Permalink
Merge pull request #399 from criticalmanufacturing/development
Browse files Browse the repository at this point in the history
release 4.2.2
  • Loading branch information
m-s- authored Apr 29, 2024
2 parents fce7fe6 + 6c299bc commit 2b8fe56
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 7 deletions.
16 changes: 16 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

### [4.2.2](https://github.com/criticalmanufacturing/cli/compare/4.2.2-1...4.2.2) (2024-04-29)

### [4.2.2-1](https://github.com/criticalmanufacturing/cli/compare/4.2.2-0...4.2.2-1) (2024-04-22)


### Bug Fixes

* **runner:** consider /usr/local installations as global ([65148a2](https://github.com/criticalmanufacturing/cli/commits/65148a2805718d9cb2a6f817ccd1bb2db2053b31))

### [4.2.2-0](https://github.com/criticalmanufacturing/cli/compare/4.2.1...4.2.2-0) (2024-04-21)


### Bug Fixes

* **plugins:** allow instant streaming of plugin outputs and errors ([0fe1dab](https://github.com/criticalmanufacturing/cli/commits/0fe1dab4a9907d52fc6381fe505b748dbc403a97))

### [4.2.1](https://github.com/criticalmanufacturing/cli/compare/4.2.1-0...4.2.1) (2024-04-21)

### [4.2.1-0](https://github.com/criticalmanufacturing/cli/compare/4.2.0...4.2.1-0) (2024-04-16)
Expand Down
36 changes: 35 additions & 1 deletion cmf-cli/Commands/plugin/PluginCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
using System.CommandLine.NamingConventionBinder;
using System.CommandLine.Parsing;
using System.Diagnostics;
using Cmf.CLI.Core;
using Cmf.CLI.Core.Enums;
using Cmf.CLI.Utilities;

namespace Cmf.CLI.Commands
{
Expand Down Expand Up @@ -62,10 +65,41 @@ public void Execute(IReadOnlyCollection<string> args)
args.ToList().ForEach(arg => ps.ArgumentList.Add(arg));
ps.UseShellExecute = false;
ps.RedirectStandardOutput = true;
ps.RedirectStandardError = true;

Action<string> outputHandler = Console.WriteLine;
Action<string> errorHandler = Log.Error;

using var process = System.Diagnostics.Process.Start(ps);
Console.WriteLine(process.StandardOutput.ReadToEnd());
if (process == null)
{
throw new Exception("Could not spawn child command");
}

process.ErrorDataReceived += (sender, args) => errorHandler(args.Data);
process.OutputDataReceived += (sender, args) => outputHandler(args.Data);

process.BeginOutputReadLine();
process.BeginErrorReadLine();

Console.CancelKeyPress += (sender, eventArgs) =>
{
eventArgs.Cancel = true;
Log.Debug("Caught SIGINT, terminating child process");
process.Disposed += (sender, args) => Log.Debug("Child process Disposed");
process.Kill(entireProcessTree: true);
Environment.Exit(-1);
};
process.WaitForExit();
var exitCode = process.ExitCode;
Log.Debug($"Child process exited with code {exitCode}");

if (exitCode != 0)
{
Log.Debug($"Plugin did not complete successfully: {exitCode}.");

throw new CliException($"{commandName} {string.Join(" ", args)} did not finished successfully.", (ErrorCode)exitCode);
}
}
}
}
2 changes: 1 addition & 1 deletion cmf-cli/cmf.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<DefaultDocumentationFileNameMode>Name</DefaultDocumentationFileNameMode>
<DefaultDocumentationNestedTypeVisibility>Namespace</DefaultDocumentationNestedTypeVisibility>
<DefaultDocumentationGeneratedPages>Namespaces</DefaultDocumentationGeneratedPages>
<Version>4.2.1</Version>
<Version>4.2.2</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion core/core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFramework>net6.0</TargetFramework>
<PackageId>CriticalManufacturing.CLI.Core</PackageId>
<RootNamespace>Cmf.CLI.Core</RootNamespace>
<Version>4.2.1</Version>
<Version>4.2.2</Version>
<Authors>CriticalManufacturing</Authors>
<Company>CriticalManufacturing</Company>
<PackageLicenseExpression>BSD-3-Clause</PackageLicenseExpression>
Expand Down
4 changes: 2 additions & 2 deletions npm/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion npm/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@criticalmanufacturing/cli",
"version": "4.2.1",
"version": "4.2.2",
"description": "Critical Manufacturing command line client",
"bin": {
"cmf": "./run.js"
Expand Down
2 changes: 1 addition & 1 deletion npm/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ debug("Determining if cli is installed globally or locally...");
* However, this does not cover some cases, depending on how Node was installed, that we need to check manually:
* - in windows, Node was installed in Program Files but NPM is installed in the user profile (AppData/Roaming)
*/
if (isInstalledGlobally || isPathInside(__dirname, process.env.APPDATA || "dummy")) {
if (isInstalledGlobally || isPathInside(__dirname, process.env.APPDATA || "dummy") || isPathInside(__dirname, "/usr/local")) {
debug("cli is installed globally. Getting binary location from user profile...");
const paths = envPaths("cmf-cli", {suffix: ""});
exePath = path.join(paths.data, opts.binName);
Expand Down

0 comments on commit 2b8fe56

Please sign in to comment.