You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
919 B
37 lines
919 B
const State = require('../State')
|
|
|
|
class PackageState extends State {
|
|
constructor(host, config) {
|
|
if ( !host.packages ) {
|
|
throw new Error(`Cannot apply package state to host ${host.name}: missing package manager API.`)
|
|
}
|
|
super(host, config)
|
|
}
|
|
|
|
async apply() {
|
|
return this._host.packages.install(this._config.package)
|
|
}
|
|
|
|
async check() {
|
|
return this._host.packages.is_installed(this._config.package)
|
|
}
|
|
|
|
async reverse() {
|
|
return this._host.packages.uninstall(this._config.package)
|
|
}
|
|
|
|
failure_message() {
|
|
return `The package "${this._config.package}" is not installed on host "${this._host.name}."`
|
|
}
|
|
|
|
check_message() {
|
|
return this.failure_message()
|
|
}
|
|
|
|
display() {
|
|
return `Ensure that the package ${this._config.package} is installed...`
|
|
}
|
|
}
|
|
|
|
module.exports = exports = PackageState
|