|
| 1 | +namespace Cake.Npm.DistTag |
| 2 | +{ |
| 3 | + using Cake.Core; |
| 4 | + using Cake.Core.IO; |
| 5 | + using System; |
| 6 | + using System.Linq; |
| 7 | + |
| 8 | + /// <summary> |
| 9 | + /// Contains settings used by <see cref="NpmDistTagTool"/> to add distribution tags. |
| 10 | + /// </summary> |
| 11 | + public class NpmDistTagAddSettings : BaseNpmDistTagSettings |
| 12 | + { |
| 13 | + /// <summary> |
| 14 | + /// Initializes a new instance of the <see cref="NpmDistTagAddSettings"/> class. |
| 15 | + /// </summary> |
| 16 | + /// <param name="packageName">Package to which the tag should be added.</param> |
| 17 | + /// <param name="packageVersion">The package version on which the tag will be applied</param> |
| 18 | + public NpmDistTagAddSettings(string packageName, string packageVersion) |
| 19 | + { |
| 20 | + if (string.IsNullOrWhiteSpace(packageName)) |
| 21 | + { |
| 22 | + throw new ArgumentNullException(nameof(packageName)); |
| 23 | + } |
| 24 | + |
| 25 | + if (string.IsNullOrWhiteSpace(packageVersion)) |
| 26 | + { |
| 27 | + throw new ArgumentNullException(nameof(packageVersion)); |
| 28 | + } |
| 29 | + |
| 30 | + PackageName = packageName; |
| 31 | + PacakgeVersion = packageVersion; |
| 32 | + } |
| 33 | + |
| 34 | + /// <summary> |
| 35 | + /// Gets the bane of the package on which the tag should be applied. |
| 36 | + /// </summary> |
| 37 | + public string PackageName { get; } |
| 38 | + |
| 39 | + /// <summary> |
| 40 | + /// Gets the vrsion of the package on which the tag will be applied. |
| 41 | + /// </summary> |
| 42 | + public string PacakgeVersion { get; } |
| 43 | + |
| 44 | + /// <summary> |
| 45 | + /// Gets or sets the tag to be added. |
| 46 | + /// </summary> |
| 47 | + public string Tag { get; set; } |
| 48 | + |
| 49 | + /// <summary> |
| 50 | + /// Evaluates the settings and writes them to <paramref name="args" />. |
| 51 | + /// </summary> |
| 52 | + /// <param name="args">The argument builder into which the settings should be written.</param> |
| 53 | + protected override void EvaluateCore(ProcessArgumentBuilder args) |
| 54 | + { |
| 55 | + base.EvaluateCore(args); |
| 56 | + |
| 57 | + args.Append("add"); |
| 58 | + args.Append($"{PackageName}@{PacakgeVersion}"); |
| 59 | + |
| 60 | + if (!string.IsNullOrWhiteSpace(Tag)) |
| 61 | + { |
| 62 | + args.Append(Tag); |
| 63 | + } |
| 64 | + } |
| 65 | + } |
| 66 | +} |
0 commit comments