Created
October 24, 2017 13:24
-
-
Save rismoney/5210fd5aaaebdc689c1d239f65b4f584 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import-module au | |
function au_BeforeUpdate() { | |
Invoke-WebRequest -Uri ($Latest.URL64) -outfile "$($env:au_chocopackagepath)\$($Latest.packagename)\$($Latest.filename)" -UseBasicParsing | out-null | |
} | |
function global:au_SearchReplace { | |
@{ | |
'tools\chocolateyInstall.ps1' = @{ | |
"(^\s*url64bit\s*=\s*)('.*')" = "`$1'$($Latest.internalsite)'" | |
"(^\s*checksum64\s*=\s*)('.*')" = "`$1'$($Latest.checksum64)'" | |
} | |
} | |
} | |
function global:au_GetLatest { | |
$packagename = "notepadplusplus" | |
$upstream_Url = 'https://notepad-plus-plus.org' | |
$download_page = Invoke-WebRequest -Uri ($upstream_Url + "/download") -UseBasicParsing | |
$re = '/npp..*.Installer.x64.exe' | |
$url = $download_page.links | Where-Object href -match $re | Select-Object -First 1 -expand href | |
$filename = $URL.Substring($URL.LastIndexOf("/") + 1) | |
$version = $url -replace "^.*npp\.([0-9\.]+)\.Installer.x64.exe$", '$1' | |
$is = "$($env:au_chocopackages)/$($packagename)/$($filename)" | |
@{ URL64 = $upstream_Url + $url | |
Version = $version | |
internalsite = $is | |
packagename = $packagename | |
filename = $filename | |
} | |
} | |
Update-Package -ChecksumFor 64 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
PS D:\gitrepos\chocopackages\notepadplusplus> .\update.ps1
notepadplusplus - checking updates using au version 2017.8.30
URL check
https://notepad-plus-plus.org/repository/7.x/7.5.1/npp.7.5.1.Installer.x64.exe
nuspec version: 7.5.0
remote version: 7.5.1
New version is available
Automatic checksum started
WARNING: Import failed for 'C:\Users\dao.rich\AppData\Local\Temp\chocolatey\au\chocolatey\extensions\chocolatey\chocolatey.licensed.dll'. If it depends on a newer version of the .NET framework, please make sure you are using the built-in PowerShell Host. Error: 'Could
not load file or assembly 'choco, Version=0.10.4.0, Culture=neutral, PublicKeyToken=79d02ea9cad655eb' or one of its dependencies. The system cannot find the file specified.'
Attempt to get headers for https://chocopackages.myorg.corp/notepadplusplus/npp.7.5.1.Installer.x64.exe failed.
The remote file either doesn't exist, is unauthorized, or is forbidden for url 'https://chocopackages.myorg.corp/notepadplusplus/npp.7.5.1.Installer.x64.exe'. Exception calling "GetResponse" with "0" argument(s): "The remote server returned an error: (404) Not Fo
."
Downloading notepadplusplus 64 bit
from 'https://chocopackages.myorg.corp/notepadplusplus/npp.7.5.1.Installer.x64.exe'
The remote file either doesn't exist, is unauthorized, or is forbidden for url 'https://chocopackages.myorg.corp/notepadplusplus/npp.7.5.1.Installer.x64.exe'. Exception calling "GetResponse" with "0" argument(s): "The remote server returned an error: (404) Not
Found."
At C:\Users\dao.rich\AppData\Local\Temp\chocolatey\au\chocolatey\helpers\functions\Get-WebFile.ps1:331 char:8
rned an error: (404) Not Found."
PS D:\gitrepos\chocopackages>