34 lines
791 B
JavaScript
34 lines
791 B
JavaScript
const AbstractGitState = require('./AbstractGitState')
|
|
|
|
class CloneState extends AbstractGitState {
|
|
|
|
async apply() {
|
|
if ( !(await this.check()) ) {
|
|
const repo = await this._repo()
|
|
await repo.clone(this._config.source)
|
|
}
|
|
}
|
|
|
|
async check() {
|
|
const repo = await this._repo()
|
|
return repo.is_repo()
|
|
}
|
|
|
|
async reverse() {
|
|
if ( await this.check() ) {
|
|
const path = await this._host.get_path(this._config.path)
|
|
await path.unlink()
|
|
}
|
|
}
|
|
|
|
failure_message() {
|
|
return `Could not find the cloned Git repo at "${this._config.path}" on host "${this._host.name}."`
|
|
}
|
|
|
|
check_message() {
|
|
return this.failure_message()
|
|
}
|
|
}
|
|
|
|
module.exports = exports = CloneState
|