Add command state
This commit is contained in:
parent
24c18e4277
commit
904a4be1b1
26
app/classes/state/os/CommandState.js
Normal file
26
app/classes/state/os/CommandState.js
Normal file
@ -0,0 +1,26 @@
|
||||
const State = require('../State')
|
||||
|
||||
class CommandState extends State {
|
||||
static get services() {
|
||||
return [...super.services, 'output']
|
||||
}
|
||||
|
||||
async apply() {
|
||||
const cmd = `${this._config.cmd}`
|
||||
await this._host.run(cmd)
|
||||
}
|
||||
|
||||
async check() {
|
||||
return false
|
||||
}
|
||||
|
||||
async reverse() {
|
||||
if ( this._config.reverse ) {
|
||||
const cmd = `${this._config.reverse}`
|
||||
await this._host.run(cmd)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = exports = CommandState
|
@ -24,6 +24,8 @@ class StatesService extends Service {
|
||||
'fs.permission': require('../classes/state/fs/PermissionState'),
|
||||
'fs.ownership': require('../classes/state/fs/OwnerState'),
|
||||
|
||||
'os.cmd': require('../classes/state/os/CommandState'),
|
||||
|
||||
'package.present': require('../classes/state/os/PackageState'),
|
||||
'package.updates': require('../classes/state/os/UpdateState'),
|
||||
'package.cache.clear': require('../classes/state/os/PackageCacheClearedState'),
|
||||
|
Loading…
Reference in New Issue
Block a user