nodejs 自动更新程序不断获取消息,使用“git pull”保持最新

问题描述

我正在创建一个需要自动更新的 nodejs 应用程序。

我尝试使用 github 上教程中发布的标准代码,但是当我第一次使用 git pull 下载所有内容,然后运行 ​​index.js 时出现错误 -> 使用“git pull”更新,

虽然当我执行 git pull myurl master 时,它说我已经是最新的

enter image description here

完整代码

var AutoUpdater = require('auto-updater');

var autoupdater = new AutoUpdater({
 pathToJson: '',autoupdate: false,checkgit: true,jsonhost: 'raw.githubusercontent.com',contenthost: 'codeload.github.com',progressDebounce: 0,devmode: false
});

// State the events
autoupdater.on('git-clone',function() {
  console.log("You have a clone of the repository. Use 'git pull' to be up-to-date");
});
autoupdater.on('check.up-to-date',function(v) {
  console.info("You have the latest version: " + v);
});
autoupdater.on('check.out-dated',function(v_old,v) {
  console.warn("Your version is outdated. " + v_old + " of " + v);
  autoupdater.fire('download-update'); // If autoupdate: false,you'll have to do this manually.
  // Maybe ask if the'd like to download the update.
});
autoupdater.on('update.downloaded',function() {
  console.log("Update downloaded and ready for install");
  autoupdater.fire('extract'); // If autoupdate: false,you'll have to do this manually.
});
autoupdater.on('update.not-installed',function() {
  console.log("The Update was already in your folder! It's read for install");
  autoupdater.fire('extract'); // If autoupdate: false,you'll have to do this manually.
});
autoupdater.on('update.extracted',function() {
  console.log("Update extracted successfully!");
  console.warn("RESTART THE APP!");
});
autoupdater.on('download.start',function(name) {
  console.log("Starting downloading: " + name);
});
autoupdater.on('download.progress',function(name,perc) {
  process.stdout.write("Downloading " + perc + "% \033[0G");
});
autoupdater.on('download.end',function(name) {
  console.log("Downloaded " + name);
});
autoupdater.on('download.error',function(err) {
  console.error("Error when downloading: " + err);
});
autoupdater.on('end',function() {
  console.log("The app is ready to function");
});
autoupdater.on('error',e) {
  console.error(name,e);
});

// Start checking
autoupdater.fire('check');

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)