2020-03-06 15:49:08 +00:00
|
|
|
const State = require('../State')
|
|
|
|
|
|
|
|
class PackageAbsentState extends State {
|
|
|
|
constructor(host, config) {
|
|
|
|
if ( !host.packages ) {
|
|
|
|
throw new Error(`Cannot apply package absent state to host ${host.name}: missing package manager API.`)
|
|
|
|
}
|
|
|
|
super(host, config)
|
|
|
|
}
|
|
|
|
|
|
|
|
async reverse() {
|
|
|
|
return this._host.packages.install(this._config.package)
|
|
|
|
}
|
|
|
|
|
|
|
|
async check() {
|
|
|
|
return !(await this._host.packages.is_installed(this._config.package))
|
|
|
|
}
|
|
|
|
|
|
|
|
async apply() {
|
|
|
|
return this._host.packages.uninstall(this._config.package)
|
|
|
|
}
|
2020-04-15 14:11:10 +00:00
|
|
|
|
|
|
|
failure_message() {
|
|
|
|
return `The package "${this._config.package}" still exists on host "${this._host.name}."`
|
|
|
|
}
|
|
|
|
|
|
|
|
check_message() {
|
|
|
|
return this.failure_message()
|
|
|
|
}
|
2020-03-06 15:49:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = exports = PackageAbsentState
|