plugin/updater: use api.log

Massimo Melina committed Jun 16, 2022 at 00:31 UTC 3ead98e69f03268c6817e493b1a7efecfa8e42a6
3 files changed +15 -10
dev-plugins.md
+2 -1
@@ -176,8 +176,9 @@ HFS will scan through them in alphabetical order searching for a compatible one.
176 - api.subscribeConfig
177 - api.setConfig
178 - api.getHfsConfig
179 -- 3
179 +- 3 (v0.21.0)
180 - config.defaultValue
181 - async for init/unload
182 + - api.log
183 - 2
184 - config.type:array
plugins/updater-disabled/plugin.js
+10 -8
@@ -1,7 +1,11 @@
1 /*
2 -this plugin is currently working only with exe version.
2 +this plugin is currently experimental and working only with exe version.
3 Its capability is to offer automatic restart when an update is available in the form of hfs.exe-new file.
4 - */
4 +*/
5 +exports.version = 0.1
6 +exports.description = "automatic restart when an update is available in the form of hfs.exe-new file"
7 +exports.apiRequired = 3 // api.log
8 +
9 const NEW = 'hfs.exe-new'
10 const BATCH_NAME = 'run-updater.bat'
11 const BATCH = `@echo off
@@ -17,20 +21,18 @@ if exist hfs.exe-new (
21 )
22 `
23
20 -const LOG_PREFIX = "UPDATER PLUGIN:"
21 -
24 exports.init = async api => {
25 const fs = api.require('fs')
26 fs.writeFile(BATCH_NAME, BATCH, err =>
25 - err && console.error(LOG_PREFIX, "couldn't write", BATCH_NAME))
27 + err && api.log("couldn't write", BATCH_NAME))
28 if (!process.env.hfs_updater)
27 - return console.log(LOG_PREFIX, "run", BATCH_NAME, "to have restart-on-update")
29 + return api.log("run", BATCH_NAME, "to have restart-on-update")
30
29 - console.log(LOG_PREFIX, "ready")
31 + api.log("ready")
32 const timer = setInterval(() => {
33 fs.access(NEW, fs.constants.W_OK, err => {
34 if (err) return
33 - console.log(LOG_PREFIX, "exiting for update")
35 + api.log("exiting for update")
36 process.exit(0)
37 })
38 }, 5000)
todo.md
+3 -1
@@ -30,7 +30,9 @@
30 - if positive search 'assets' array for 'name' matching exe, and download 'browser_download_url', and replace exe
31 - upload
32 - upload unzipping (while streaming?)
33 -- plugin to automatic generate letsencrypt cert?
33 +- plugin to make letsencrypt easier
34 + - could be just automatic detection of files by certbot
35 + - letsencrypt supports plugins to automatically configure webservers
36 - delete
37 - updater (stop,unzip,start)
38 - node.comment