CodeSampleX

샘플

electron-updater 6.8.9: BaseUpdater

검증된 샘플 — npm electron-updater 6.8.9: BaseUpdater. node 22 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: BaseUpdater extends AppUpdater and provides…

sha256:9426064223b81fe144cb4dc8e138e94f48b393a4eddc1b29f8a7503fefc5401e

이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다. 통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다. MIT-0

실행 증거

선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.

증거 기준
서명된 컨트랙트 통과
검증 영수증
1
빌드한 서명 키
1
선언된 환경 node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

검증 실행 환경

환경 컨트랙트 단계 실행일
node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1node:22-alpine@sha256:c610fcdfb1d5…
2026-08-26

케이스

HOW
목표
verify BaseUpdater in pkg:npm/electron-updater@6.8.9
패키지
심벌
  • BaseUpdater
환경
node 22.23.2
생성일
2026-08-26T10:50:26Z

컨트랙트

  1. BaseUpdater extends AppUpdater and provides base functionality for platform updaters
  2. BaseUpdater.sanitizeEnvPath strips relative path segments from PATH environment variable
  3. BaseUpdater.spawnSyncLog executes child process command synchronously with sanitized PATH and returns trimmed stdout
  4. BaseUpdater.spawnLog spawns detached child process asynchronously
  5. BaseUpdater.installerPath returns null before download and points to downloaded file after download
  6. BaseUpdater.install emits error when invoked before update file is downloaded
  7. BaseUpdater.executeDownload coordinates update download and emits progress and completion events
  8. BaseUpdater.install delegates to doInstall with correct silent and forceRun options
  9. BaseUpdater.addQuitHandler registers quit listener on app adapter when autoInstallOnAppQuit is enabled

파일

  • PROMPT.md
  • csx.json
  • index.js
  • package-lock.json
  • package.json
  • spec.json
  • test/contract.js

소스 아티팩트 내려받기 (tar.gz)

소스

PROMPT.md
Clean-room public code sample — generation instructions

Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.

A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.

Goal: verify BaseUpdater in pkg:npm/electron-updater@6.8.9
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/electron-updater@6.8.9
Demonstrate these symbols/APIs:
  - BaseUpdater
Constraints:
  - executionContext: node
Required runtime conditions:
  - ecosystem: npm
  - language: javascript
  - moduleSystem: cjs
  - packageManager: npm@10.9.8
  - runtime: node@22.23.2

Rules:
  - One focused purpose; the smallest project that proves the goal.
  - Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
  - Pin every dependency with a lockfile so resolution is reproducible.
  - No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
  - No personal names, emails, company names, or project identifiers of any kind.
  - No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
  - Keep it under 200 files and 256KB packed.
csx.json
{"case":{"caseId":"case:sha256:8cb000241f87d2006fa02715a847e69971fe877fb799f2b62c84ac956c8df68f","constraints":{"executionContext":"node"},"contract":["BaseUpdater extends AppUpdater and provides base functionality for platform updaters","BaseUpdater.sanitizeEnvPath strips relative path segments from PATH environment variable","BaseUpdater.spawnSyncLog executes child process command synchronously with sanitized PATH and returns trimmed stdout","BaseUpdater.spawnLog spawns detached child process asynchronously","BaseUpdater.installerPath returns null before download and points to downloaded file after download","BaseUpdater.install emits error when invoked before update file is downloaded","BaseUpdater.executeDownload coordinates update download and emits progress and completion events","BaseUpdater.install delegates to doInstall with correct silent and forceRun options","BaseUpdater.addQuitHandler registers quit listener on app adapter when autoInstallOnAppQuit is enabled"],"goal":"verify BaseUpdater in pkg:npm/electron-updater@6.8.9","kind":"HOW","packages":["pkg:npm/electron-updater@6.8.9"],"schemaVersion":1,"symbols":["BaseUpdater"]},"contractCommand":["node","test/contract.js"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"cjs","os":"linux","osVersionBucket":"24","packageManager":"npm","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/electron-updater@6.8.9"],"schemaVersion":1,"subject":"pkg:npm/electron-updater@6.8.9","symbols":["BaseUpdater"],"verifierAdapter":"node-typescript@1"}
index.js
const http = require("http");
const {
  BaseUpdater,
  AppUpdater,
  CancellationToken,
  NoOpLogger,
  DOWNLOAD_PROGRESS,
  UPDATE_DOWNLOADED,
} = require("electron-updater");
const { findFile } = require("electron-updater/out/providers/Provider");
const { HttpExecutor, configureRequestUrl, configureRequestOptions } = require("builder-util-runtime");

class NodeHttpExecutor extends HttpExecutor {
  async download(url, destination, options) {
    return await options.cancellationToken.createPromise((resolve, reject, onCancel) => {
      const requestOptions = {
        headers: options.headers || undefined,
        redirect: "manual",
      };
      configureRequestUrl(url, requestOptions);
      configureRequestOptions(requestOptions);
      this.doDownload(
        requestOptions,
        {
          destination,
          options,
          onCancel,
          callback: (error) => {
            if (error == null) {
              resolve(destination);
            } else {
              reject(error);
            }
          },
          responseHandler: null,
        },
        0
      );
    });
  }

  createRequest(options, callback) {
    return http.request(options, callback);
  }
}

class StandaloneAppAdapter {
  constructor(options = {}) {
    this.version = options.version || "1.0.0";
    this.name = options.name || "sample-updater-app";
    this.isPackaged = options.isPackaged !== undefined ? options.isPackaged : true;
    this.appUpdateConfigPath = options.appUpdateConfigPath || "";
    this.userDataPath = options.userDataPath || "";
    this.baseCachePath = options.baseCachePath || "";
    this._quitHandlers = [];
    this.quitCalled = false;
  }

  async whenReady() {}

  relaunch() {}

  quit() {
    this.quitCalled = true;
    for (const handler of this._quitHandlers) {
      handler(0);
    }
  }

  onQuit(handler) {
    this._quitHandlers.push(handler);
  }
}

class CustomBaseUpdater extends BaseUpdater {
  constructor(options, app) {
    super(options, app);
    this.installedOptions = null;
  }

  doDownloadUpdate(downloadUpdateOptions) {
    const provider = downloadUpdateOptions.updateInfoAndProvider.provider;
    const fileInfo = findFile(provider.resolveFiles(downloadUpdateOptions.updateInfoAndProvider.info), "exe");
    return this.executeDownload({
      fileExtension: "exe",
      downloadUpdateOptions,
      fileInfo,
      task: async (destinationFile, downloadOptions) => {
        await this.httpExecutor.download(fileInfo.url, destinationFile, downloadOptions);
      },
    });
  }

  doInstall(options) {
    this.installedOptions = options;
    return true;
  }
}

function createBaseUpdater(options = null, appAdapter = null, feedUrl = null) {
  const app = appAdapter || new StandaloneAppAdapter();
  const updater = new CustomBaseUpdater(options, app);
  updater.httpExecutor = new NodeHttpExecutor();
  if (feedUrl) {
    updater.setFeedURL({
      provider: "generic",
      url: feedUrl,
    });
  }
  updater.logger = new NoOpLogger();
  updater.autoDownload = false;
  return updater;
}

module.exports = {
  BaseUpdater,
  AppUpdater,
  CustomBaseUpdater,
  StandaloneAppAdapter,
  NodeHttpExecutor,
  createBaseUpdater,
  CancellationToken,
  NoOpLogger,
  DOWNLOAD_PROGRESS,
  UPDATE_DOWNLOADED,
};
package-lock.json
{
  "name": "electron-updater-baseupdater-sample",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "electron-updater-baseupdater-sample",
      "version": "1.0.0",
      "dependencies": {
        "electron-updater": "6.8.9"
      }
    },
    "node_modules/argparse": {
      "version": "2.0.1",
      "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz",
      "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==",
      "license": "Python-2.0"
    },
    "node_modules/builder-util-runtime": {
      "version": "9.7.0",
      "resolved": "https://registry.npmjs.org/builder-util-runtime/-/builder-util-runtime-9.7.0.tgz",
      "integrity": "sha512-g/kR520giAFYkSXTzcmF3kqQq7wi8F6N6SzeDgZrqTBN+VHdmgWOyTdD1yD7AATDId/yXLvuP34CxW46/BwCdw==",
      "license": "MIT",
      "dependencies": {
        "debug": "^4.3.4",
        "sax": "^1.2.4"
      },
      "engines": {
        "node": ">=12.0.0"
      }
    },
    "node_modules/debug": {
      "version": "4.4.3",
      "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz",
      "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==",
      "license": "MIT",
      "dependencies": {
        "ms": "^2.1.3"
      },
      "engines": {
        "node": ">=6.0"
      },
      "peerDependenciesMeta": {
        "supports-color": {
          "optional": true
        }
      }
    },
    "node_modules/electron-updater": {
      "version": "6.8.9",
      "resolved": "https://registry.npmjs.org/electron-updater/-/electron-updater-6.8.9.tgz",
      "integrity": "sha512-ZhVxM9iGONUpZGI1FxdMRgJjUFXi7AYGVa5PwKlO1tV1/4zDxQmfKpXOHVztKrd6L9rLcFjERvi1Mf2vxyTkig==",
      "license": "MIT",
      "dependencies": {
        "builder-util-runtime": "9.7.0",
        "fs-extra": "^10.1.0",
        "js-yaml": "^4.1.0",
        "lazy-val": "^1.0.5",
        "lodash.escaperegexp": "^4.1.2",
        "lodash.isequal": "^4.5.0",
        "semver": "~7.7.3",
        "tiny-typed-emitter": "^2.1.0"
      }
    },
    "node_modules/fs-extra": {
      "version": "10.1.0",
      "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz",
      "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==",
      "license": "MIT",
      "dependencies": {
        "graceful-fs": "^4.2.0",
        "jsonfile": "^6.0.1",
        "universalify": "^2.0.0"
      },
      "engines": {
        "node": ">=12"
      }
    },
    "node_modules/graceful-fs": {
      "version": "4.2.11",
      "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz",
      "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==",
      "license": "ISC"
    },
    "node_modules/js-yaml": {
      "version": "4.3.1",
      "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.3.1.tgz",
      "integrity": "sha512-CY6crGq313MX8GkwvB7tzgp99vjQxY1++5y10/BKN/GUfHqWaOGQMNZkBvqSzsZKWk/ijwHlWzzkLulsGHhjWQ==",
      "funding": [
        {
          "type": "github",
          "url": "https://github.com/sponsors/puzrin"
        },
        {
          "type": "github",
          "url": "https://github.com/sponsors/nodeca"
        }
      ],
      "license": "MIT",
      "dependencies": {
        "argparse": "^2.0.1"
      },
      "bin": {
        "js-yaml": "bin/js-yaml.js"
      }
    },
    "node_modules/jsonfile": {
      "version": "6.2.1",
      "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.2.1.tgz",
      "integrity": "sha512-zwOTdL3rFQ/lRdBnntKVOX6k5cKJwEc1HdilT71BWEu7J41gXIB2MRp+vxduPSwZJPWBxEzv4yH1wYLJGUHX4Q==",
      "license": "MIT",
      "dependencies": {
        "universalify": "^2.0.0"
      },
      "optionalDependencies": {
        "graceful-fs": "^4.1.6"
      }
    },
    "node_modules/lazy-val": {
      "version": "1.0.5",
      "resolved": "https://registry.npmjs.org/lazy-val/-/lazy-val-1.0.5.tgz",
      "integrity": "sha512-0/BnGCCfyUMkBpeDgWihanIAF9JmZhHBgUhEqzvf+adhNGLoP6TaiI5oF8oyb3I45P+PcnrqihSf01M0l0G5+Q==",
      "license": "MIT"
    },
    "node_modules/lodash.escaperegexp": {
      "version": "4.1.2",
      "resolved": "https://registry.npmjs.org/lodash.escaperegexp/-/lodash.escaperegexp-4.1.2.tgz",
      "integrity": "sha512-TM9YBvyC84ZxE3rgfefxUWiQKLilstD6k7PTGt6wfbtXF8ixIJLOL3VYyV/z+ZiPLsVxAsKAFVwWlWeb2Y8Yyw==",
      "license": "MIT"
    },
    "node_modules/lodash.isequal": {
      "version": "4.5.0",
      "resolved": "https://registry.npmjs.org/lodash.isequal/-/lodash.isequal-4.5.0.tgz",
      "integrity": "sha512-pDo3lu8Jhfjqls6GkMgpahsF9kCyayhgykjyLMNFTKWrpVdAQtYyB4muAMWozBB4ig/dtWAmsMxLEI8wuz+DYQ==",
      "deprecated": "This package is deprecated. Use require('node:util').isDeepStrictEqual instead.",
      "license": "MIT"
    },
    "node_modules/ms": {
      "version": "2.1.3",
      "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
      "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
      "license": "MIT"
    },
    "node_modules/sax": {
      "version": "1.6.1",
      "resolved": "https://registry.npmjs.org/sax/-/sax-1.6.1.tgz",
      "integrity": "sha512-42tBVwLWnaQvW5zc4HbZrTuWccECCZfBi92FDuwtqxasH+JbPB3/FOKb1m222K42R4WxuxzzMsTswfzgtSu64Q==",
      "license": "BlueOak-1.0.0",
      "engines": {
        "node": ">=11.0.0"
      }
    },
    "node_modules/semver": {
      "version": "7.7.4",
      "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.4.tgz",
      "integrity": "sha512-vFKC2IEtQnVhpT78h1Yp8wzwrf8CM+MzKMHGJZfBtzhZNycRFnXsHk6E5TxIkkMsgNS7mdX3AGB7x2QM2di4lA==",
      "license": "ISC",
      "bin": {
        "semver": "bin/semver.js"
      },
      "engines": {
        "node": ">=10"
      }
    },
    "node_modules/tiny-typed-emitter": {
      "version": "2.1.0",
      "resolved": "https://registry.npmjs.org/tiny-typed-emitter/-/tiny-typed-emitter-2.1.0.tgz",
      "integrity": "sha512-qVtvMxeXbVej0cQWKqVSSAHmKZEHAvxdF8HEUBFWts8h+xEo5m/lEiPakuyZ3BnCBjOD8i24kzNOiOLLgsSxhA==",
      "license": "MIT"
    },
    "node_modules/universalify": {
      "version": "2.0.1",
      "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz",
      "integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==",
      "license": "MIT",
      "engines": {
        "node": ">= 10.0.0"
      }
    }
  }
}
package.json
{
  "name": "electron-updater-baseupdater-sample",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room verification sample for BaseUpdater in electron-updater",
  "main": "index.js",
  "scripts": {
    "test": "node test/contract.js"
  },
  "dependencies": {
    "electron-updater": "6.8.9"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify BaseUpdater in pkg:npm/electron-updater@6.8.9",
  "kind": "HOW",
  "packages": [
    "pkg:npm/electron-updater@6.8.9"
  ],
  "symbols": [
    "BaseUpdater"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "packageManager": "npm@10.9.8",
    "runtime": "node@22.23.2"
  }
}
test/contract.js
const assert = require("assert");
const http = require("http");
const path = require("path");
const os = require("os");
const fs = require("fs");
const crypto = require("crypto");
const {
  BaseUpdater,
  AppUpdater,
  CustomBaseUpdater,
  StandaloneAppAdapter,
  createBaseUpdater,
  CancellationToken,
  NoOpLogger,
  DOWNLOAD_PROGRESS,
  UPDATE_DOWNLOADED,
} = require("../index.js");

async function main() {
  // 1. Inheritance and class structure
  assert.strictEqual(typeof BaseUpdater, "function", "BaseUpdater should be a constructor");
  assert.strictEqual(Object.getPrototypeOf(BaseUpdater.prototype), AppUpdater.prototype, "BaseUpdater should extend AppUpdater");

  const appAdapter = new StandaloneAppAdapter({ version: "1.0.0", name: "test-app" });
  const updater = new CustomBaseUpdater(null, appAdapter);
  updater.logger = new NoOpLogger();

  // 2. sanitizeEnvPath contract: strips relative paths from PATH
  const rawPath = ["/usr/local/bin", "./relative/bin", "/usr/bin", "bin", "/bin"].join(path.delimiter);
  const sanitizedPath = updater.sanitizeEnvPath(rawPath);
  const expectedPath = ["/usr/local/bin", "/usr/bin", "/bin"].join(path.delimiter);
  assert.strictEqual(sanitizedPath, expectedPath, "sanitizeEnvPath should retain only absolute path segments");

  // 3. spawnSyncLog contract: executes command and captures stdout
  const syncOutput = updater.spawnSyncLog("echo", ["spawnSyncLog-ok"]);
  assert.strictEqual(syncOutput, "spawnSyncLog-ok", "spawnSyncLog should return trimmed stdout");

  // 4. spawnLog contract: async process spawn
  const spawnResult = await updater.spawnLog("node", ["-e", "process.exit(0)"]);
  assert.strictEqual(spawnResult, true, "spawnLog should resolve true on successful process spawn");

  // 5. installerPath contract before download
  assert.strictEqual(updater.installerPath, null, "installerPath should be null before any download");

  // 6. install failure contract when no update is downloaded
  let errorDispatched = null;
  updater.once("error", (err) => {
    errorDispatched = err;
  });
  const installResultNoFile = updater.install(false, false);
  assert.strictEqual(installResultNoFile, false, "install should return false when no update downloaded");
  assert(errorDispatched instanceof Error, "error event should be emitted when install called without downloaded file");

  // 7. Temporary environment and mock HTTP update server for download & install verification
  const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "electron-updater-base-test-"));
  const userDataDir = path.join(tempDir, "userData");
  const cacheDir = path.join(tempDir, "cache");
  const configPath = path.join(tempDir, "app-update.yml");
  fs.mkdirSync(userDataDir, { recursive: true });
  fs.mkdirSync(cacheDir, { recursive: true });
  fs.writeFileSync(configPath, "provider: generic\n");

  const configuredApp = new StandaloneAppAdapter({
    version: "1.0.0",
    name: "contract-base-app",
    isPackaged: true,
    appUpdateConfigPath: configPath,
    userDataPath: userDataDir,
    baseCachePath: cacheDir,
  });

  const installerPayload = Buffer.from("electron-updater-base-test-payload");
  const installerSha512 = crypto.createHash("sha512").update(installerPayload).digest("base64");

  const server = http.createServer((req, res) => {
    if (req.url.includes(".yml") || req.url.includes("latest")) {
      const ymlContent = `version: 2.0.0
files:
  - url: base-updater-setup-2.0.0.exe
    sha512: ${installerSha512}
    size: ${installerPayload.length}
    isAdminRightsRequired: false
path: base-updater-setup-2.0.0.exe
sha512: ${installerSha512}
releaseDate: 2026-01-01T00:00:00.000Z
`;
      res.writeHead(200, { "Content-Type": "text/yaml" });
      res.end(ymlContent);
    } else if (req.url.includes("base-updater-setup-2.0.0.exe")) {
      res.writeHead(200, {
        "Content-Type": "application/octet-stream",
        "Content-Length": installerPayload.length,
      });
      res.end(installerPayload);
    } else {
      res.writeHead(404);
      res.end();
    }
  });

  await new Promise((resolve) => server.listen(0, "127.0.0.1", resolve));
  const serverPort = server.address().port;
  const feedUrl = `http://127.0.0.1:${serverPort}`;

  try {
    const liveUpdater = createBaseUpdater(null, configuredApp, feedUrl);

    // Check for updates
    let availableEmitted = false;
    liveUpdater.on("update-available", (info) => {
      availableEmitted = true;
      assert.strictEqual(info.version, "2.0.0", "update-available version should match feed");
    });

    const checkResult = await liveUpdater.checkForUpdates();
    assert(checkResult, "checkForUpdates result should exist");
    assert.strictEqual(availableEmitted, true, "update-available event should have fired");

    // Download update
    let downloadProgressEmitted = false;
    let updateDownloadedEmitted = false;
    liveUpdater.on(DOWNLOAD_PROGRESS, (progress) => {
      downloadProgressEmitted = true;
      assert(progress.percent >= 0 && progress.percent <= 100, "progress percent within bounds");
    });
    liveUpdater.on(UPDATE_DOWNLOADED, (info) => {
      updateDownloadedEmitted = true;
      assert.strictEqual(info.version, "2.0.0", "update-downloaded info version should match");
    });

    const downloadedFiles = await liveUpdater.downloadUpdate();
    assert(Array.isArray(downloadedFiles) && downloadedFiles.length > 0, "downloadedFiles should be non-empty");
    assert.strictEqual(downloadProgressEmitted, true, "DOWNLOAD_PROGRESS event should fire");
    assert.strictEqual(updateDownloadedEmitted, true, "UPDATE_DOWNLOADED event should fire");

    // 8. installerPath and install() execution on downloaded update
    assert(liveUpdater.installerPath != null, "installerPath should be populated after download");
    assert.strictEqual(liveUpdater.installerPath, downloadedFiles[0], "installerPath should match downloaded file");
    assert(fs.existsSync(liveUpdater.installerPath), "downloaded installer file should exist on disk");

    const installSuccess = liveUpdater.install(true, false);
    assert.strictEqual(installSuccess, true, "install should return true from doInstall");
    assert.deepStrictEqual(
      liveUpdater.installedOptions,
      { isSilent: true, isForceRunAfter: false, isAdminRightsRequired: false },
      "doInstall should receive proper installation options"
    );

    // 9. addQuitHandler contract
    const quitApp = new StandaloneAppAdapter({
      version: "1.0.0",
      name: "quit-test-app",
      isPackaged: true,
      appUpdateConfigPath: configPath,
      userDataPath: userDataDir,
      baseCachePath: cacheDir,
    });
    const quitUpdater = createBaseUpdater(null, quitApp, feedUrl);
    quitUpdater.autoInstallOnAppQuit = true;
    assert.strictEqual(quitUpdater.quitHandlerAdded, false, "quitHandlerAdded should be false initially");
    quitUpdater.addQuitHandler();
    assert.strictEqual(quitUpdater.quitHandlerAdded, true, "quitHandlerAdded should be true after addQuitHandler");

    console.log("All BaseUpdater contract tests passed successfully.");
  } finally {
    server.close();
    fs.rmSync(tempDir, { recursive: true, force: true });
  }
}

main().catch((err) => {
  console.error("Contract test failed:", err);
  process.exit(1);
});

오리진 시더

익명