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.
maestro/app/classes/state/git/CloneState.js

34 lines
789 B

const State = require('../State')
const Repository = require('../../git/Repository')
class CloneState extends State {
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()
}
}
async _repo() {
const path = await this._host.get_path(this._config.path)
if ( !path.is_valid() ) await path.touch(true)
return new Repository(path)
}
}
module.exports = exports = CloneState