Skip to content

Updates for Update-PSResource #534

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Nov 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,167 changes: 2,167 additions & 0 deletions Notice.txt

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions doBuild.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ function DoBuild
Copy-Item -Path "./LICENSE" -Dest "$BuildOutPath"

# Copy notice
# Write-Verbose -Verbose -Message "Copying ThirdPartyNotices.txt to '$BuildOutPath'"
# Copy-Item -Path "./ThirdPartyNotices.txt" -Dest "$BuildOutPath"
Write-Verbose -Verbose -Message "Copying ThirdPartyNotices.txt to '$BuildOutPath'"
Copy-Item -Path "./Notice.txt" -Dest "$BuildOutPath"

#
# Copy DSC resources
Expand Down
31 changes: 19 additions & 12 deletions src/code/FindPSResource.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using Microsoft.PowerShell.PowerShellGet.UtilClasses;
using System;
using System.Collections.Generic;
using Dbg = System.Diagnostics.Debug;
using System.Linq;
using System.Management.Automation;
using System.Threading;
using Microsoft.PowerShell.PowerShellGet.UtilClasses;

using Dbg = System.Diagnostics.Debug;

namespace Microsoft.PowerShell.PowerShellGet.Cmdlets
{
Expand All @@ -29,8 +30,8 @@ public sealed class FindPSResource : PSCmdlet
private const string ResourceNameParameterSet = "ResourceNameParameterSet";
private const string CommandNameParameterSet = "CommandNameParameterSet";
private const string DscResourceNameParameterSet = "DscResourceNameParameterSet";
private CancellationTokenSource _source;
private CancellationToken _cancellationToken;
private CancellationTokenSource _cancellationTokenSource;
private FindHelper _findHelper;

#endregion

Expand Down Expand Up @@ -132,17 +133,25 @@ public sealed class FindPSResource : PSCmdlet

protected override void BeginProcessing()
{
_source = new CancellationTokenSource();
_cancellationToken = _source.Token;
_cancellationTokenSource = new CancellationTokenSource();
_findHelper = new FindHelper(
cancellationToken: _cancellationTokenSource.Token,
cmdletPassedIn: this);

// Create a respository story (the PSResourceRepository.xml file) if it does not already exist
// Create a repository story (the PSResourceRepository.xml file) if it does not already exist
// This is to create a better experience for those who have just installed v3 and want to get up and running quickly
RepositorySettings.CheckRepositoryStore();
}

protected override void StopProcessing()
{
_source.Cancel();
_cancellationTokenSource?.Cancel();
}

protected override void EndProcessing()
{
_cancellationTokenSource.Dispose();
_cancellationTokenSource = null;
}

protected override void ProcessRecord()
Expand Down Expand Up @@ -207,10 +216,9 @@ private void ProcessResourceNameParameterSet()
return;
}

FindHelper findHelper = new FindHelper(_cancellationToken, this);
List<PSResourceInfo> foundPackages = new List<PSResourceInfo>();

foreach (PSResourceInfo package in findHelper.FindByResourceName(
foreach (PSResourceInfo package in _findHelper.FindByResourceName(
Name,
Type,
Version,
Expand Down Expand Up @@ -283,10 +291,9 @@ private void ProcessCommandOrDscParameterSet(bool isSearchingForCommands)
moduleNamesToSearch = new string[] {"*"};
}

FindHelper findHelper = new FindHelper(_cancellationToken, this);
List<PSResourceInfo> foundPackages = new List<PSResourceInfo>();

foreach (PSResourceInfo package in findHelper.FindByResourceName(
foreach (PSResourceInfo package in _findHelper.FindByResourceName(
name: moduleNamesToSearch,
// provide type so Scripts endpoint for PSGallery won't be searched
type: isSearchingForCommands? ResourceType.Command : ResourceType.DscResource,
Expand Down
Loading