or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

auto-updater.mdconfiguration.mdcore-updaters.mdevents.mdindex.mdplatform-updaters.mdproviders.mdtypes.md
tile.json

auto-updater.mddocs/

Auto Updater

The main autoUpdater constant provides a platform-specific updater instance that is automatically selected based on the current operating system. This is the primary interface most applications will use for implementing auto-update functionality.

Capabilities

Auto Updater Instance

The platform-specific updater instance automatically selected at runtime.

/**
 * Platform-specific updater instance automatically selected based on current OS:
 * - Windows: NsisUpdater
 * - macOS: MacUpdater  
 * - Linux: AppImageUpdater (with fallback to DebUpdater/RpmUpdater/PacmanUpdater based on package-type)
 */
declare const autoUpdater: AppUpdater;

Platform Selection Logic:

  • Windows (win32): Uses NsisUpdater for NSIS installer-based updates
  • macOS (darwin): Uses MacUpdater for Squirrel.Mac-based updates
  • Linux: Uses AppImageUpdater by default, with automatic detection of package managers:
    • Checks for package-type file in process.resourcesPath
    • Falls back to DebUpdater, RpmUpdater, or PacmanUpdater based on detected package type

Usage Examples:

import { autoUpdater } from "electron-updater";

// Basic setup
autoUpdater.setFeedURL("https://your-update-server.com");
autoUpdater.checkForUpdates();

// With GitHub
autoUpdater.setFeedURL({
  provider: "github",
  owner: "your-username", 
  repo: "your-app-repo"
});

// Check for updates manually
const result = await autoUpdater.checkForUpdates();
if (result?.isUpdateAvailable) {
  console.log("Update available:", result.updateInfo.version);
}

// Download update manually (when autoDownload is false)
autoUpdater.autoDownload = false;
autoUpdater.on("update-available", async () => {
  try {
    await autoUpdater.downloadUpdate();
  } catch (error) {
    console.error("Download failed:", error);
  }
});

// Install update
autoUpdater.on("update-downloaded", () => {
  // Show user notification, then restart
  autoUpdater.quitAndInstall();
});

Configuration Properties

All properties from the AppUpdater base class are available on the autoUpdater instance:

// Automatic behavior controls
autoUpdater.autoDownload = true;              // Auto-download when update found
autoUpdater.autoInstallOnAppQuit = true;      // Auto-install on app quit
autoUpdater.autoRunAppAfterInstall = true;    // Run app after installation

// Update filtering
autoUpdater.allowPrerelease = false;          // Allow pre-release versions
autoUpdater.allowDowngrade = false;           // Allow version downgrades
autoUpdater.fullChangelog = false;            // Get complete changelog (GitHub)

// Channel and versioning
autoUpdater.channel = "stable";               // Update channel (stable/beta/alpha)

// Request configuration  
autoUpdater.requestHeaders = {                // Custom HTTP headers
  "Authorization": "token your-token"
};

// Logging
autoUpdater.logger = console;                 // Logger instance
autoUpdater.logger = null;                    // Disable logging

// Development and testing
autoUpdater.forceDevUpdateConfig = false;     // Force dev mode config

Main Methods

/**
 * Configure the update provider and server
 * @param options Provider configuration or URL string
 */
setFeedURL(options: PublishConfiguration | AllPublishOptions | string): void;

/**
 * Check for available updates on the server
 * @returns Promise resolving to update check result or null if updater inactive
 */
checkForUpdates(): Promise<UpdateCheckResult | null>;

/**
 * Check for updates and show system notification when update is downloaded
 * @param downloadNotification Optional notification customization
 * @returns Promise resolving to update check result
 */
checkForUpdatesAndNotify(downloadNotification?: DownloadNotification): Promise<UpdateCheckResult | null>;

/**
 * Manually download an available update
 * @param cancellationToken Optional cancellation token
 * @returns Promise resolving to array of downloaded file paths
 */
downloadUpdate(cancellationToken?: CancellationToken): Promise<Array<string>>;

/**
 * Quit the application and install the downloaded update
 * @param isSilent Install silently without user interaction (Windows only)
 * @param isForceRunAfter Force run app after installation (Windows only)
 */
quitAndInstall(isSilent?: boolean, isForceRunAfter?: boolean): void;

/**
 * Check if the updater is currently active (packaged app or dev mode forced)
 * @returns true if updater will check for updates
 */
isUpdaterActive(): boolean;

/**
 * Add authorization header to requests
 * @param token Authorization token
 */
addAuthHeader(token: string): void;

Event Handling

The autoUpdater supports both traditional EventEmitter events and type-safe signal handlers:

// Traditional event listeners
autoUpdater.on("checking-for-update", () => {
  console.log("Checking for update...");
});

autoUpdater.on("update-available", (info: UpdateInfo) => {
  console.log("Update available:", info.version);
});

autoUpdater.on("update-not-available", (info: UpdateInfo) => {
  console.log("Up to date");
});

autoUpdater.on("error", (err: Error) => {
  console.log("Error in auto-updater:", err);
});

autoUpdater.on("download-progress", (progressObj: ProgressInfo) => {
  console.log(`Downloaded ${progressObj.percent}%`);
});

autoUpdater.on("update-downloaded", (info: UpdateDownloadedEvent) => {
  console.log("Update downloaded, will install on quit");
});

// Type-safe signal handlers
autoUpdater.signals.progress((progressInfo) => {
  console.log(`Progress: ${progressInfo.percent}%`);
});

autoUpdater.signals.updateDownloaded((info) => {
  console.log("Downloaded:", info.downloadedFile);
});

autoUpdater.signals.login((authInfo, callback) => {
  // Handle proxy authentication
  callback("username", "password");
});

Error Handling

autoUpdater.on("error", (error: Error, message?: string) => {
  console.error("Auto updater error:", error);
  
  // Common error scenarios:
  if (error.message.includes("ERR_UPDATER_INVALID_VERSION")) {
    console.error("Invalid version format in update info");
  } else if (error.message.includes("ERR_UPDATER_NO_FILES_PROVIDED")) {
    console.error("No update files available");
  } else if (error.message.includes("ENOTFOUND")) {
    console.error("Update server not reachable");
  }
});

// Handle update cancellation
autoUpdater.on("update-cancelled", (info: UpdateInfo) => {
  console.log("Update cancelled:", info.version);
});

Advanced Configuration

// Custom update support verification
autoUpdater.isUpdateSupported = (updateInfo) => {
  // Custom logic to determine if update is supported
  const currentOS = process.platform;
  const minVersion = updateInfo.minimumSystemVersion;
  return someCustomCheck(currentOS, minVersion);
};

// Custom rollout verification  
autoUpdater.isUserWithinRollout = (updateInfo) => {
  // Custom logic for staged rollouts
  const userSegment = getUserSegment();
  const rolloutPercentage = updateInfo.stagingPercentage || 100;
  return userSegment < rolloutPercentage;
};

// Differential download configuration (Windows only)
autoUpdater.disableDifferentialDownload = false;

// Web installer configuration
autoUpdater.disableWebInstaller = false;

// Custom blockmap URL (for GitHub releases)
autoUpdater.previousBlockmapBaseUrlOverride = "https://custom-cdn.com/releases/";