Add support for routines; state messages

This commit is contained in:
garrettmills
2020-04-15 09:11:10 -05:00
parent e401809ad5
commit 8319859828
36 changed files with 1146 additions and 22 deletions

View File

@@ -26,6 +26,14 @@ class DirectoryState extends State {
async _path() {
return this._host.get_path(this._config.path)
}
failure_message() {
return `The path "${this._config.path}" does not exist on host "${this._host.name}."`
}
check_message() {
return this.failure_message()
}
}
module.exports = exports = DirectoryState

View File

@@ -46,6 +46,14 @@ class DownloadState extends State {
if ( !this._config.path ) throw new Error('Missing path config for DownloadState.')
return this._host.get_path(this._config.path)
}
failure_message() {
return `The downloaded file "${this._config.path}" does not exist on host "${this._host.name}."`
}
check_message() {
return this.failure_message()
}
}
module.exports = exports = DownloadState

View File

@@ -31,6 +31,14 @@ class FileState extends State {
if ( !this._config.path ) throw new Error('Missing path config for FileState.')
return this._host.get_path(this._config.path)
}
failure_message() {
return `The file "${this._config.path}" does not exist on the host "${this._host.name}."`
}
check_message() {
return this.failure_message()
}
}
module.exports = exports = FileState

View File

@@ -39,6 +39,13 @@ class OwnerState extends State {
return path
}
failure_message() {
return `The ownership state of the file "${this._config.path}" on host "${this._host.name}" is invalid.`
}
check_message() {
return this.failure_message()
}
}
module.exports = exports = OwnerState

View File

@@ -55,6 +55,14 @@ class PackState extends State {
if ( !path.is_valid() ) throw new Error(`Invalid path for PathState: ${path}`)
return path
}
failure_message() {
return `The archive "${this._config.destination}" does not exist on the host "${this._host.name}."`
}
check_message() {
return this.failure_message()
}
}
module.exports = exports = PackState

View File

@@ -34,6 +34,14 @@ class PermissionState extends State {
if ( !path.is_valid() ) throw new Error(`Invalid path for PermissionState: ${path}`)
return path
}
failure_message() {
return `The resource permissions for "${this._config.path}" on host "${this._host.name}" are invalid.`
}
check_message() {
return this.failure_message()
}
}
module.exports = exports = PermissionState

View File

@@ -58,6 +58,14 @@ class UnpackState extends State {
if ( !path.is_directory() ) throw new Error(`Invalid extraction path. Must be a directory: ${path}`)
return path
}
failure_message() {
return `The unpacked archive does not exist at the path "${this._config.destination}" on host "${this._host.name}."`
}
check_message() {
return this.failure_message()
}
}
module.exports = exports = UnpackState