Skip to content

Changing back to non-zipped compatibility profiles #1179

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 3 commits into from
Mar 21, 2019
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
22 changes: 0 additions & 22 deletions Rules/CompatibilityRules/CompatibilityRule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,9 @@ public abstract class CompatibilityRule : ConfigurableRule
// The name of the directory where compatibility profiles are looked for by default.
private const string PROFILE_DIR_NAME = "compatibility_profiles";

// The name of the file to hydrate the compatibility profile assets from.
private const string PROFILE_ZIP_NAME = "compatibility_profiles.zip";

// The full path of the directory where compatiblity profiles are looked for by default.
private static readonly string s_defaultProfileDirPath;

// The full path of the file where the zipped compatibility profiles are.
private static readonly string s_profileZipPath;

// Memoized path to the module root of PSScriptAnalyzer.
private static readonly Lazy<string> s_moduleRootDirPath;

Expand All @@ -45,10 +39,6 @@ static CompatibilityRule()
{
s_moduleRootDirPath = new Lazy<string>(() => GetModuleRootDirPath());
s_defaultProfileDirPath = Path.Combine(s_moduleRootDirPath.Value, PROFILE_DIR_NAME);
s_profileZipPath = Path.Combine(s_moduleRootDirPath.Value, PROFILE_ZIP_NAME);

// On first run, we need to make sure the profile assets have been hydrated from the zip
ExpandZipToDirectory(s_profileZipPath, s_defaultProfileDirPath);
}

private readonly CompatibilityProfileLoader _profileLoader;
Expand Down Expand Up @@ -238,18 +228,6 @@ private static string GetModuleRootDirPath()
return Path.GetFullPath(nonNormalizedRoot);
}

private static void ExpandZipToDirectory(string zipPath, string destinationDirectoryPath)
{
// Assume that if the directory already exists, there is nothing to do.
// Profile unzipping can be forced by deleting the directory.
if (Directory.Exists(destinationDirectoryPath))
{
return;
}

// Note: This method will throw if the directory already exists
ZipFile.ExtractToDirectory(zipPath, destinationDirectoryPath, Encoding.UTF8);
}
}

/// <summary>
Expand Down
19 changes: 2 additions & 17 deletions build.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -118,24 +118,9 @@ function Copy-CompatibilityProfiles
}

$profileDir = [System.IO.Path]::Combine($PSScriptRoot, 'PSCompatibilityAnalyzer', 'profiles')
$destinationDir = [System.IO.Path]::Combine($PSScriptRoot, 'out', 'PSScriptAnalyzer')
$destination = Join-Path $destinationDir 'compatibility_profiles.zip'
$destinationDir = [System.IO.Path]::Combine($PSScriptRoot, 'out', 'PSScriptAnalyzer', "compatibility_profiles")

if (Test-Path -LiteralPath $destinationDir -PathType Container)
{
Remove-Item -Force -Recurse $destination -ErrorAction Ignore
}
else
{
$null = New-Item -Path $destinationDir -ItemType Directory
}

[System.IO.Compression.ZipFile]::CreateFromDirectory(
$profileDir,
$destination,
[System.IO.Compression.CompressionLevel]::Optimal,
<# includeBaseDirectory #> $false,
[System.Text.Encoding]::UTF8)
Copy-Item -Recurse $profileDir $destinationDir
}

# build script analyzer (and optionally build everything with -All)
Expand Down