Skip to content

Commit

Permalink
feat: Add pre|post_uninstall (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ash258 authored May 16, 2020
1 parent 20f7706 commit 7a6f458
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
20 changes: 20 additions & 0 deletions lib/uninstall.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,23 @@
. "$PSScriptRoot\$_.ps1"
}

# TODO: Refactor
function pre_uninstall($manifest, $arch) {
$pre = arch_specific 'pre_uninstall' $manifest $arch
if ($pre) {
Write-UserMessage -Message 'Running pre-uninstall script...'
Invoke-Expression (@($pre) -join "`r`n")
}
}

function post_uninstall($manifest, $arch) {
$post = arch_specific 'post_uninstall' $manifest $arch
if ($post) {
Write-UserMessage -Message 'Running post-uninstall script...'
Invoke-Expression (@($post) -join "`r`n")
}
}

function Uninstall-ScoopApplication {
<#
.SYNOPSIS
Expand Down Expand Up @@ -55,7 +72,10 @@ function Uninstall-ScoopApplication {
$install = install_info $App $version $Global
$architecture = $install.architecture

pre_uninstall $manifest $architecture
run_uninstaller $manifest $architecture $dir
post_uninstall $manifest $architecture

rm_shims $manifest $Global $architecture
rm_startmenu_shortcuts $manifest $Global $architecture

Expand Down
16 changes: 16 additions & 0 deletions schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,18 @@
"description": "PowerShell commands to be executed after 'installer' is invoked and after persist/binaries and shortcuts creation.",
"$ref": "#/definitions/stringOrArrayOfStrings"
},
"pre_uninstall": {
"description": "PowerShell commands to be executed before 'uninstaller' is invoked.",
"$ref": "#/definitions/stringOrArrayOfStrings"
},
"uninstaller": {
"description": "Specify the process of application uninstallation.",
"$ref": "#/definitions/uninstaller"
},
"post_uninstall": {
"description": "PowerShell commands to be executed after 'uninstaller' is invoked.",
"$ref": "#/definitions/stringOrArrayOfStrings"
},
"bin": {
"description": "Specify executables to be available in PATH.",
"$ref": "#/definitions/stringOrArrayOfStringsOrAnArrayOfArrayOfStrings"
Expand Down Expand Up @@ -562,10 +570,18 @@
"description": "PowerShell commands to be executed after 'installer' is invoked and after persist/binaries and shortcuts creation.",
"$ref": "#/definitions/stringOrArrayOfStrings"
},
"pre_uninstall": {
"description": "PowerShell commands to be executed before 'uninstaller' is invoked.",
"$ref": "#/definitions/stringOrArrayOfStrings"
},
"uninstaller": {
"description": "Specify the process of application uninstallation.",
"$ref": "#/definitions/uninstaller"
},
"post_uninstall": {
"description": "PowerShell commands to be executed after 'uninstaller' is invoked.",
"$ref": "#/definitions/stringOrArrayOfStrings"
},
"psmodule": {
"description": "Specify PowerShell module installation",
"type": "object",
Expand Down

0 comments on commit 7a6f458

Please sign in to comment.