Git auto-sync/commit

Hope it helps

silverbullet.registerEventListener({name: "editor:pageSaved"}, async (event) => {
  // Clear the existing timeout if the function is called again before the delay
  if (debounceTimeout) {
    clearTimeout(debounceTimeout);
  }

  // Set a new timeout
  debounceTimeout = setTimeout(async () => {
    try {
      // Invoke the git sync command
      await system.invokeFunction("git.syncCommand");
      console.log("Git sync command executed successfully.");
    } catch (error) {
      console.error("Failed to execute Git sync command:", error);
    }
  }, 60000 * 5); // 5 minute delay
});
1 Like