25 lines
615 B
JavaScript
25 lines
615 B
JavaScript
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)
|
|
}
|
|
}
|
|
|
|
module.exports = exports = PackageState
|