-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Replace IDE watcher to integrated watcher and use it as demon for this mode.
On change, compile with inject dev script as lualib and add to files .build with timestamp/hash.
Dev scripts
AutoRestart:
Looking .build file on the root resouce dir and on change restart resource.
import '.build' //Hello from https://github.com/mtasa-typescript/mtasa-lua-utils/issues/401
new (class AutoRestart {
private fileName = '.build'
private build = ''
private interval = 5 //interval checks
private wait = 5 //wait before restart
private debug = false //show debug
private timer: Timer
constructor() {
this.build = this.getResourceBuild()
this.timer = setTimer(() => { this.checkBuild() }, this.interval * 1000, 0)
}
getResourceBuild () : string {
if (fileExists(this.fileName)) {
const file = fileOpen(this.fileName, true)
const build = fileRead(file, fileGetSize(file))
fileClose(file)
return build
} else return this.build
}
checkBuild() : void {
if (this.build !== this.getResourceBuild()) {
outputServerLog(`Build changed! Restart after ${this.wait} seconds...`)
killTimer(this.timer)
setTimer(() => {
restartResource(getThisResource())
}, this.wait * 1000, 1)
} else if (this.debug) outputServerLog(`Build: ${this.build}/${this.getResourceBuild()}`)
}
})Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request