npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@osmn-byhn/changelog-github-updater

v1.0.3

Published

This library is an OS-agnostic auto-updater for your Node.js or Electron-based applications (Windows, macOS, Linux) that allows you to easily perform automatic updates via **Github Releases**.

Readme

@osmn-byhn/changelog-github-updater

This library is an OS-agnostic auto-updater for your Node.js or Electron-based applications (Windows, macOS, Linux) that allows you to easily perform automatic updates via Github Releases.

Powered by @osmn-byhn/changelog-github-core, it checks for the latest release in your GitHub repository, automatically detects the correct asset depending on the user's operating system, downloads it, and initiates the installation process. Throughout this flow, your application's user data (such as userData, cache) is kept completely safe.

Features

  • Cross-Platform Support: Automatically detects win32, darwin (macOS), and linux operating systems.
  • Smart Extension Matching: Finds and downloads the appropriate installation file depending on the OS (.exe, .dmg, .zip, .deb, .AppImage).
  • Preserves User Data: Downloaded files are moved to a secure temporary folder and triggered for installation from there, ensuring your application settings and user data remain untouched.
  • Flexible Configuration: Pass your own temporary directory (tempPath), fallback to current package version (currentVersion), or prevent auto-install (autoInstall: false) if you prefer to customize the flow.
  • Middleware Support: Allows defining asynchronous functions (middleware) to execute arbitrary code before the downloaded update is applied (e.g., displaying a notification or backing up databases).

Installation

You can include the project via npm:

npm install @osmn-byhn/changelog-github-updater

Usage Example

The library supports both TypeScript and CommonJS environments seamlessly. The core functionality is provided through the updateIfNeeded method.

1. TypeScript / ES Modules Usage

If you are using TypeScript or a modern toolchain (like Vite):

import { updateIfNeeded } from "@osmn-byhn/changelog-github-updater";
import { app } from "electron"; // Electron example

async function checkUpdates() {
    try {
        const result = await updateIfNeeded({
            owner: "YourUsername", // GitHub Username/Organization
            repo: "YourRepo",      // GitHub Repository Name
            currentVersion: app.getVersion(), // (Optional) The current version of your application
            autoInstall: true                 // Automatically install the update when downloaded
        });

        if (result.updated) {
            console.log(`Update downloaded and installation started! Version: ${result.from} -> ${result.to}`);
        } else {
            console.log("Your application is up to date.");
        }
    } catch (error) {
        console.error("An error occurred while checking for updates:", error);
    }
}

checkUpdates();

2. Standard Native JavaScript (CommonJS/Node.js) Usage

If you are developing a standard Node.js script or setting up main.js inside an older Electron boilerplate without Webpack/Vite:

const { updateIfNeeded } = require("@osmn-byhn/changelog-github-updater");
const { app } = require("electron");

async function checkUpdates() {
    try {
        const result = await updateIfNeeded({
            owner: "YourUsername",
            repo: "YourRepo",
            currentVersion: app.getVersion(), 
            autoInstall: true
        });

        if (result.updated) {
            console.log(`Update applied! Version: ${result.from} -> ${result.to}`);
        } else {
            console.log("Up to date.");
        }
    } catch (error) {
        console.error("Update error:", error);
    }
}

checkUpdates();

Parameters (UpdaterOptions)

The options you can pass directly to updateIfNeeded:

| Parameter | Type | Description | |-----------------|-----------|-------------| | owner | string | Required. The owner of the GitHub repository. (e.g., "osmn-byhn") | | repo | string | Required. The name of the GitHub repository. (e.g., "my-electron-app") | | currentVersion | string | Optional. If you want to explicitly provide the current version. If omitted, the library checks its stored current version. | | tempPath | string | Optional. By default os.tmpdir() is used. You can override where the downloaded file is temporarily placed. | | autoInstall | boolean | Optional. Set to false if you want to download but not execute the installer. Defaults to true. |

Using Middleware (Optional)

If you need to intercept the installation process when an update is found but before files are downloaded/installed:

const myMiddleware = async (oldVersion: string, newVersion: string) => {
    console.log(`Updating version. Old: ${oldVersion}, New: ${newVersion}`);
    // e.g. Send a notification, take a database backup...
};

await updateIfNeeded({ owner: "osmn-byhn", repo: "my-app" }, myMiddleware);

Under the Hood (Platform Execution Behavior)

Once the file is safely downloaded, the library invokes these processes:

  • Windows (.exe): Executed in the background (detached: true) and exits the main Node process.
  • macOS (.dmg, .zip): Executed via the OS's native open command to mount/run the image or archive.
  • Linux (.deb, etc.): pkexec dpkg -i is fired for deb packages (which might prompt a GUI for the user's sudo password). .AppImage files are marked as executable and are spawned directly.

Important Note: In order for the library to work properly, you must publish your release binaries (.exe, .deb, etc.) as Assets inside your GitHub Releases page.

Contributing

If you want to build the project locally in your own environment:

# Install dependencies
npm install

# Compile TypeScript files
npm run build

License: ISC