Skip to content

Commit e87839e

Browse files
committed
refactor(helper): create helper folder for scripts with helper functions
1 parent 9784acd commit e87839e

File tree

9 files changed

+17
-12
lines changed

9 files changed

+17
-12
lines changed

bin/checkhashes.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ param(
4242

4343
. "$PSScriptRoot\..\lib\core.ps1"
4444
. "$PSScriptRoot\..\lib\manifest.ps1"
45-
. "$PSScriptRoot\..\lib\hash.ps1" # 'get_hash'
45+
. "$PSScriptRoot\..\lib\helper\hash.ps1" # 'get_hash'
4646
. "$PSScriptRoot\..\lib\buckets.ps1"
4747
. "$PSScriptRoot\..\lib\autoupdate.ps1"
4848
. "$PSScriptRoot\..\lib\json.ps1"

lib/autoupdate.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Must included with 'json.ps1'
22

3-
. "$PSScriptRoot\..\lib\hash.ps1" # 'get_hash'
3+
. "$PSScriptRoot\..\lib\helper\hash.ps1" # 'get_hash'
44

55
function format_hash([String] $hash) {
66
$hash = $hash.toLower()

lib/download.ps1

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# Description: Functions for downloading files
22

33
. "$PSScriptRoot\..\lib\core.ps1"
4-
. "$PSScriptRoot\..\lib\hash.ps1" # 'hash_for_url'
4+
. "$PSScriptRoot\..\lib\helper\hash.ps1" # 'hash_for_url'
5+
. "$PSScriptRoot\..\lib\helper\file-information.ps1" # 'Get-RemoteFileSize'
56
. "$PSScriptRoot\..\lib\virustotal.ps1"
67

78
## Meta downloader
@@ -681,12 +682,6 @@ function get_magic_bytes_pretty($file, $glue = ' ') {
681682
return (get_magic_bytes $file | ForEach-Object { $_.ToString('x2') }) -join $glue
682683
}
683684

684-
function Get-RemoteFileSize ($Uri) {
685-
$response = Invoke-WebRequest -Uri $Uri -Method HEAD -UseBasicParsing
686-
if (!$response.Headers.StatusCode) {
687-
$response.Headers.'Content-Length' | ForEach-Object { [int]$_ }
688-
}
689-
}
690685

691686
function ftp_file_size($url) {
692687
$request = [net.ftpwebrequest]::create($url)

lib/helper/file-information.ps1

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
### Remote file information
2+
3+
function Get-RemoteFileSize ($Uri) {
4+
$response = Invoke-WebRequest -Uri $Uri -Method HEAD -UseBasicParsing
5+
if (!$response.Headers.StatusCode) {
6+
$response.Headers.'Content-Length' | ForEach-Object { [int]$_ }
7+
}
8+
}
File renamed without changes.

lib/virustotal.ps1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
. "$PSScriptRoot\json.ps1" # 'json_path'
2-
. "$PSScriptRoot\..\lib\hash.ps1" # 'hash_for_url'
2+
. "$PSScriptRoot\..\lib\helper\hash.ps1" # 'hash_for_url'
3+
. "$PSScriptRoot\..\lib\helper\file-information.ps1" # 'Get-RemoteFileSize'
34

45
# Error codes
56
$script:_ERR_UNSAFE = 2

libexec/scoop-download.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
. "$PSScriptRoot\..\lib\getopt.ps1"
2424
. "$PSScriptRoot\..\lib\json.ps1" # 'autoupdate.ps1' (indirectly)
25-
. "$PSScriptRoot\..\lib\hash.ps1" # 'hash_for_url'
25+
. "$PSScriptRoot\..\lib\helper\hash.ps1" # 'hash_for_url'
2626
. "$PSScriptRoot\..\lib\autoupdate.ps1" # 'generate_user_manifest' (indirectly)
2727
. "$PSScriptRoot\..\lib\versions.ps1" # 'Select-CurrentVersion'
2828
. "$PSScriptRoot\..\lib\manifest.ps1" # 'generate_user_manifest' 'Get-Manifest'

libexec/scoop-info.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
. "$PSScriptRoot\..\lib\manifest.ps1" # 'Get-Manifest'
88
. "$PSScriptRoot\..\lib\versions.ps1" # 'Get-InstalledVersion', 'Select-CurrentVersion'
99
. "$PSScriptRoot\..\lib\download.ps1" # 'Get-RemoteFileSize'
10+
. "$PSScriptRoot\..\lib\helper\file-information.ps1" # 'Get-RemoteFileSize'
1011

1112
$opt, $app, $err = getopt $args 'v' 'verbose'
1213
$original_app = $app

libexec/scoop-update.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
. "$PSScriptRoot\..\lib\psmodules.ps1"
2323
. "$PSScriptRoot\..\lib\decompress.ps1"
2424
. "$PSScriptRoot\..\lib\manifest.ps1"
25-
. "$PSScriptRoot\..\lib\hash.ps1" # 'hash_for_url'
25+
. "$PSScriptRoot\..\lib\helper\hash.ps1" # 'hash_for_url'
2626
. "$PSScriptRoot\..\lib\versions.ps1"
2727
. "$PSScriptRoot\..\lib\depends.ps1"
2828
. "$PSScriptRoot\..\lib\install.ps1"

0 commit comments

Comments
 (0)