Skip to content

Commit

Permalink
format [shovel skip]
Browse files Browse the repository at this point in the history
  • Loading branch information
Ash258 committed Sep 5, 2020
1 parent 532d603 commit 16d5ef3
Show file tree
Hide file tree
Showing 21 changed files with 321 additions and 324 deletions.
8 changes: 4 additions & 4 deletions libexec/scoop-cache.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

param($cmd, $app)

. (Join-Path $PSScriptRoot "..\lib\help.ps1")
. (Join-Path $PSScriptRoot '..\lib\help.ps1')

Reset-Alias

Expand All @@ -26,7 +26,7 @@ function cacheinfo($file) {

function show($app) {
$files = @(Get-ChildItem $SCOOP_CACHE_DIRECTORY | Where-Object -Property Name -Match "^$app")
$total_length = ($files | Measure-Object length -sum).sum -as [double]
$total_length = ($files | Measure-Object length -Sum).sum -as [double]

$f_app = @{ 'Expression' = { "$($_.app) ($($_.version))" } }
$f_url = @{ 'Expression' = { $_.url }; 'Alignment' = 'Right' }
Expand All @@ -42,8 +42,8 @@ $exitCode = 0
switch ($cmd) {
'rm' {
if (!$app) { Stop-ScoopExecution -Message 'Parameter <app> missing' -Usage (my_usage) }
Join-Path $SCOOP_CACHE_DIRECTORY "$app#*"| Remove-Item -Force -Recurse
Join-Path $SCOOP_CACHE_DIRECTORY "$app.txt"| Remove-Item -ErrorAction SilentlyContinue -Force -Recurse
Join-Path $SCOOP_CACHE_DIRECTORY "$app#*" | Remove-Item -Force -Recurse
Join-Path $SCOOP_CACHE_DIRECTORY "$app.txt" | Remove-Item -ErrorAction SilentlyContinue -Force -Recurse
}
'show' {
show $app
Expand Down
4 changes: 2 additions & 2 deletions libexec/scoop-cleanup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ function cleanup($app, $global, $verbose, $cache) {
return
}

Write-Host "Removing ${app}:" -ForegroundColor Yellow -NoNewLine
Write-Host "Removing ${app}:" -ForegroundColor Yellow -NoNewline
$versions | ForEach-Object {
$version = $_
Write-Host " $version" -NoNewLine
Write-Host " $version" -NoNewline
$dir = versiondir $app $version $global
# unlink all potential old link before doing recursive Remove-Item
unlink_persist_data $dir
Expand Down
2 changes: 1 addition & 1 deletion libexec/scoop-config.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ if ($name -eq 'rm') {
Write-UserMessage -Message "'$name' has been set to '$value'"
} else {
$value = get_config $name
$mes = if ($null -eq $value) { "'$name' is not set" } else { $value }
$mes = if ($null -eq $value) { "'$name' is not set" } else { $value }

Write-UserMessage -Message $mes -Output
}
Expand Down
4 changes: 2 additions & 2 deletions libexec/scoop-hold.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ foreach ($app in $apps) {
$dir = versiondir $app 'current' $global
$json = install_info $app 'current' $global
if ($json.hold -and ($json.hold -eq $true)) {
Write-UserMessage -Message "'$app' is already held" -Warning
continue
Write-UserMessage -Message "'$app' is already held" -Warning
continue
}
$install = @{ }
# TODO: Add-member instead of duplicating of whole object
Expand Down
10 changes: 5 additions & 5 deletions libexec/scoop-info.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@ Write-Output "Manifest:`n $manifest_file"

if ($status.installed) {
# Show installed versions
Write-Output "Installed:"
Write-Output 'Installed:'
$versions = Get-InstalledVersion -AppName $app -Global:$global
$versions | ForEach-Object {
$dir = versiondir $app $_ $global
if ($global) { $dir += " *global*" }
if ($global) { $dir += ' *global*' }
Write-Output " $dir"
}
} else {
Write-Output "Installed: No"
Write-Output 'Installed: No'
}

$binaries = @(arch_specific 'bin' $manifest $architecture)
Expand All @@ -110,9 +110,9 @@ $env_add_path = @(arch_specific 'env_add_path' $manifest $architecture)

if ($env_set -or $env_add_path) {
if ($status.installed) {
Write-Output "Environment:"
Write-Output 'Environment:'
} else {
Write-Output "Environment: (simulated)"
Write-Output 'Environment: (simulated)'
}
}

Expand Down
2 changes: 1 addition & 1 deletion libexec/scoop-list.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ if ($apps) {
}
Write-Host ''
} else {
Write-userMessage -Message "No application installed."
Write-userMessage -Message 'No application installed.'
}

exit 0
6 changes: 3 additions & 3 deletions libexec/scoop-search.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function download_json($url) {
}

function github_ratelimit_reached {
return (download_json "https://api.github.com/rate_limit").Rate.Remaining -eq 0
return (download_json 'https://api.github.com/rate_limit').Rate.Remaining -eq 0
}

function search_remote($bucket, $query) {
Expand Down Expand Up @@ -91,7 +91,7 @@ function search_remotes($query) {
$results | ForEach-Object {
"'$($_.bucket)' bucket:"
$_.results | ForEach-Object { " $_" }
""
''
}
}

Expand All @@ -113,7 +113,7 @@ Get-LocalBucket | ForEach-Object {
if ($_.bin) { $item += " --> includes '$($_.bin)'" }
$item
}
""
''
}
}

Expand Down
7 changes: 4 additions & 3 deletions libexec/scoop-status.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ if (Join-Path $currentdir '.git' | Test-Path -PathType Container) {
if ($needs_update) {
Write-UserMessage -Message "Scoop is out of date. Run 'scoop update' to get the latest changes." -Warning
} else {
Write-UserMessage -Message "Scoop is up to date." -Success
Write-UserMessage -Message 'Scoop is up to date.' -Success
}

$failed = @()
Expand All @@ -35,11 +35,12 @@ $missing_deps = @()
$onhold = @()
$exitCode = 0

foreach ($global in ($true, $false)) { # local and global apps
# local and global apps
foreach ($global in ($true, $false)) {
$dir = appsdir $global
if (!(Test-Path $dir)) { continue }

foreach ($application in (Get-ChildItem $dir | Where-Object -Property Name -NE -Value 'scoop')){
foreach ($application in (Get-ChildItem $dir | Where-Object -Property Name -NE -Value 'scoop')) {
$app = $application.name
$status = app_status $app $global
if ($status.failed) {
Expand Down
8 changes: 4 additions & 4 deletions test/00-Project.Tests.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
$repo_dir = (Get-Item $MyInvocation.MyCommand.Path).Directory.Parent.FullName

$repo_files = @( Get-ChildItem $repo_dir -file -recurse -force )
$repo_files = @( Get-ChildItem $repo_dir -File -Recurse -Force )

$project_file_exclusions = @(
([Regex]::Escape($repo_dir) + '(\\|/).git(\\|/).*$')
Expand All @@ -21,9 +21,9 @@ Describe 'Project code' {

$files_exist = ($files.Count -gt 0)

It $('PowerShell code files exist ({0} found)' -f $files.Count) -skip:$(-not $files_exist) {
It $('PowerShell code files exist ({0} found)' -f $files.Count) -Skip:$(-not $files_exist) {
if (-not ($files.Count -gt 0)) {
throw "No PowerShell code files were found"
throw 'No PowerShell code files were found'
}
}

Expand Down Expand Up @@ -56,7 +56,7 @@ Describe 'Project code' {
}
}

It 'PowerShell code files do not contain syntax errors' -skip:$(-not $files_exist) {
It 'PowerShell code files do not contain syntax errors' -Skip:$(-not $files_exist) {
$badFiles = @(
foreach ($file in $files) {
if ( (Test-PowerShellSyntax $file.FullName).SyntaxErrorsFound ) {
Expand Down
2 changes: 1 addition & 1 deletion test/Import-Bucket-Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ if ([String]::IsNullOrEmpty($MyInvocation.PSScriptRoot)) {

$repo_dir = (Get-Item $MyInvocation.PSScriptRoot).FullName

$repo_files = @(Get-ChildItem $repo_dir -file -recurse)
$repo_files = @(Get-ChildItem $repo_dir -File -Recurse)

$project_file_exclusions = @(
$([regex]::Escape($repo_dir) + '(\\|/).git(\\|/).*$'),
Expand Down
20 changes: 10 additions & 10 deletions test/Import-File-Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ Describe 'Style constraints for non-binary project files' {

$files_exist = ($files.Count -gt 0)

It $('non-binary project files exist ({0} found)' -f $files.Count) -skip:$(-not $files_exist) {
It $('non-binary project files exist ({0} found)' -f $files.Count) -Skip:$(-not $files_exist) {
if (-not ($files.Count -gt 0)) {
throw "No non-binary project were found"
throw 'No non-binary project were found'
}
}

It 'files do not contain leading UTF-8 BOM' -skip:$(-not $files_exist) {
It 'files do not contain leading UTF-8 BOM' -Skip:$(-not $files_exist) {
# UTF-8 BOM == 0xEF 0xBB 0xBF
# see http://www.powershellmagazine.com/2012/12/17/pscxtip-how-to-determine-the-byte-order-mark-of-a-text-file @@ https://archive.is/RgT42
# ref: http://poshcode.org/2153 @@ https://archive.is/sGnnu
Expand All @@ -43,11 +43,11 @@ Describe 'Style constraints for non-binary project files' {
}
}

It 'files end with a newline' -skip:$(-not $files_exist) {
It 'files end with a newline' -Skip:$(-not $files_exist) {
$badFiles = @(
foreach ($file in $files) {
# Ignore previous TestResults.xml
if ($file -match "TestResults.xml") {
if ($file -match 'TestResults.xml') {
continue
}
$string = [System.IO.File]::ReadAllText($file.FullName)
Expand All @@ -62,10 +62,10 @@ Describe 'Style constraints for non-binary project files' {
}
}

It 'file newlines are CRLF' -skip:$(-not $files_exist) {
It 'file newlines are CRLF' -Skip:$(-not $files_exist) {
$badFiles = @(
foreach ($file in $files) {
$content = Get-Content -raw $file.FullName
$content = Get-Content -Raw $file.FullName
if (!$content) {
throw "File contents are null: $($file.FullName)"
}
Expand All @@ -86,11 +86,11 @@ Describe 'Style constraints for non-binary project files' {
}
}

It 'files have no lines containing trailing whitespace' -skip:$(-not $files_exist) {
It 'files have no lines containing trailing whitespace' -Skip:$(-not $files_exist) {
$badLines = @(
foreach ($file in $files) {
# Ignore previous TestResults.xml
if ($file -match "TestResults.xml") {
if ($file -match 'TestResults.xml') {
continue
}
$lines = [System.IO.File]::ReadAllLines($file.FullName)
Expand All @@ -109,7 +109,7 @@ Describe 'Style constraints for non-binary project files' {
}
}

It 'any leading whitespace consists only of spaces (excepting makefiles)' -skip:$(-not $files_exist) {
It 'any leading whitespace consists only of spaces (excepting makefiles)' -Skip:$(-not $files_exist) {
$badLines = @(
foreach ($file in $files) {
if ($file.fullname -inotmatch '(^|.)makefile$') {
Expand Down
16 changes: 8 additions & 8 deletions test/Scoop-Config.Tests.ps1
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
. "$PSScriptRoot\..\lib\core.ps1"

Describe "config" -Tag 'Scoop' {
Describe 'config' -Tag 'Scoop' {
BeforeAll {
$json = '{ "one": 1, "two": [ { "a": "a" }, "b", 2 ], "three": { "four": 4 }, "five": true, "six": false, "seven": "\/Date(1529917395805)\/", "eight": "2019-03-18T15:22:09.3930000+00:00" }'
}

It "converts JSON to PSObject" {
It 'converts JSON to PSObject' {
$obj = ConvertFrom-Json $json

$obj.one | Should -BeExactly 1
$obj.two[0].a | Should -Be "a"
$obj.two[1] | Should -Be "b"
$obj.two[0].a | Should -Be 'a'
$obj.two[1] | Should -Be 'b'
$obj.two[2] | Should -BeExactly 2
$obj.three.four | Should -BeExactly 4
$obj.five | Should -BeTrue
Expand All @@ -23,21 +23,21 @@ Describe "config" -Tag 'Scoop' {
}
}

It "load_config should return PSObject" {
It 'load_config should return PSObject' {
Mock Get-Content { $json }
Mock Test-Path { $true }
(load_cfg 'file') | Should -Not -BeNullOrEmpty
(load_cfg 'file') | Should -BeOfType [System.Management.Automation.PSObject]
(load_cfg 'file').one | Should -BeExactly 1
}

It "get_config should return exactly the same values" {
It 'get_config should return exactly the same values' {
$SCOOP_CONFIGURATION = ConvertFrom-Json $json
get_config 'does_not_exist' 'default' | Should -Be 'default'

get_config 'one' | Should -BeExactly 1
(get_config 'two')[0].a | Should -Be "a"
(get_config 'two')[1] | Should -Be "b"
(get_config 'two')[0].a | Should -Be 'a'
(get_config 'two')[1] | Should -Be 'b'
(get_config 'two')[2] | Should -BeExactly 2
(get_config 'three').four | Should -BeExactly 4
get_config 'five' | Should -BeTrue
Expand Down
Loading

0 comments on commit 16d5ef3

Please sign in to comment.