Skip to content

Commit

Permalink
Merge branch 'main' into feature/requirements-context
Browse files Browse the repository at this point in the history
  • Loading branch information
thomhurst authored Nov 22, 2023
2 parents 9642ade + 0c28376 commit a0b76d8
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 6 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ Define your pipeline in .NET! Strong types, intellisense, parallelisation, and t
| ModularPipelines.Terraform | Helpers for interacting with Terraform CLI. | [![nuget](https://img.shields.io/nuget/v/ModularPipelines.Terraform.svg)](https://www.nuget.org/packages/ModularPipelines.Terraform/) |
| ModularPipelines.Yarn | Helpers for interacting with Yarn CLI. | [![nuget](https://img.shields.io/nuget/v/ModularPipelines.Yarn.svg)](https://www.nuget.org/packages/ModularPipelines.Yarn/) |


## Getting Started

If you want to see how to get started, or want to know more about ModularPipelines, [read the Documentation here](https://thomhurst.github.io/ModularPipelines)
Expand Down
1 change: 1 addition & 0 deletions src/ModularPipelines.Build/ReleaseNotes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* More nvm methods
24 changes: 24 additions & 0 deletions src/ModularPipelines.Node/Nvm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,28 @@ public Task<CommandResult> Use(string version, CancellationToken cancellationTok
Arguments = new[] { "use", version },
}, cancellationToken);
}

public Task<CommandResult> Install(string version, CancellationToken cancellationToken = default)
{
return _context.Command.ExecuteCommandLineTool(new CommandLineToolOptions("nvm")
{
Arguments = new[] { "install", version },
}, cancellationToken);
}

public Task<CommandResult> Version(CancellationToken cancellationToken = default)
{
return _context.Command.ExecuteCommandLineTool(new CommandLineToolOptions("nvm")
{
Arguments = new[] { "version" },
}, cancellationToken);
}

public Task<CommandResult> Which(CancellationToken cancellationToken = default)
{
return _context.Command.ExecuteCommandLineTool(new CommandLineToolOptions("nvm")
{
Arguments = new[] { "which" },
}, cancellationToken);
}
}
14 changes: 13 additions & 1 deletion src/ModularPipelines/Options/CommandLineToolOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,20 @@ namespace ModularPipelines.Options;
/// <summary>
/// Options for setting the context of a command, the command line tool, and any arguments it needs
/// </summary>
public record CommandLineToolOptions(string Tool) : CommandLineOptions
public record CommandLineToolOptions : CommandLineOptions
{
public CommandLineToolOptions(string tool) : this(tool, null)
{
}

public CommandLineToolOptions(string tool, params string[]? arguments)
{
Tool = tool;
Arguments = arguments;
}

public string Tool { get; init; }

/// <summary>
/// Used for providing switches and arguments to the tool
/// </summary>
Expand Down
10 changes: 6 additions & 4 deletions test/ModularPipelines.UnitTests/Helpers/CommandTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ private class CommandEchoModule : Module<CommandResult>
{
protected override async Task<CommandResult?> ExecuteAsync(IPipelineContext context, CancellationToken cancellationToken)
{
return await context.Command.ExecuteCommandLineTool(new CommandLineToolOptions("pwsh")
{
Arguments = new[] { "-Command", "echo 'Foo bar!'" },
}, cancellationToken: cancellationToken);
return await context.Command.ExecuteCommandLineTool(
new CommandLineToolOptions(
"pwsh",
"-Command", "echo 'Foo bar!'"
),
cancellationToken: cancellationToken);
}
}

Expand Down

0 comments on commit a0b76d8

Please sign in to comment.