Skip to content

Commit

Permalink
fixed can not remove the lib
Browse files Browse the repository at this point in the history
  • Loading branch information
lixinyang123 committed Feb 23, 2023
1 parent 5ca6b87 commit c0c92fd
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/Commands/RemoveCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using JSDelivrCLI.Services;
using System.CommandLine;
using System.CommandLine.Binding;
using System.Diagnostics.CodeAnalysis;

namespace delivr.Commands
{
Expand All @@ -21,19 +20,21 @@ public RemoveCommand() : base("remove", "remove a package from local")
this.SetHandler(Execute, argument);
}

[RequiresDynamicCode("Calls JSDelivrCLI.Services.ConfigService.Save()")]
private void Execute(string library)
{
ConfigItem item = configService.GetLibrary(library);

if (item == null)
{
ConsoleTool.WriteColorful("Can't find this library", ConsoleColor.Red);
return;
}

if (Directory.Exists(item.Destination))
string libPath = Path.Combine(item.Destination, item.Name);

if (!string.IsNullOrEmpty(libPath))
{
Directory.Delete(item.Destination, true);
Directory.Delete(libPath, true);
}

configService.RemoveLibrary(item.Name);
Expand Down

0 comments on commit c0c92fd

Please sign in to comment.