maestro/app/classes/state/node/YarnInstallState.js

44 lines
1.1 KiB
JavaScript
Raw Permalink Normal View History

2020-11-30 08:07:47 +00:00
const State = require('../State')
class YarnInstallState extends State {
#ran_once = false
static get services() {
return [...super.services, 'output']
}
async apply() {
const cmd = `cd "${this._config.path}" && yarn install`
await this._host.run(cmd)
this.#ran_once = true
}
async check() {
if ( this._config.force ) return this.#ran_once
else {
const node_modules = this._host.get_path(`${this._config.path}/node_modules`)
await node_modules.classify()
return node_modules.is_directory()
}
}
async reverse() {
const node_modules = this._host.get_path(`${this._config.path}/node_modules`)
await node_modules.unlink()
}
failure_message() {
return `The Yarn packages at ${this._config.path} need to be installed.`
}
check_message() {
return this.failure_message()
}
display() {
return `Ensure that the Yarn packages at ${this._config.path} are installed...`
}
}
module.exports = exports = YarnInstallState