From ccc52c2573e3b506e79ae7c31036e6ba0447851e Mon Sep 17 00:00:00 2001 From: Felix Rieseberg Date: Tue, 10 Sep 2024 16:46:21 -0700 Subject: [PATCH 1/2] fix: Export a "default" property --- src/asar.ts | 15 ++++++++++++++- tsconfig.json | 3 ++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/asar.ts b/src/asar.ts index bd0f7aa..2d1b5cb 100644 --- a/src/asar.ts +++ b/src/asar.ts @@ -1,5 +1,5 @@ import * as path from 'path'; -import * as minimatch from 'minimatch'; +import minimatch from 'minimatch'; import fs from './wrapped-fs'; import { Filesystem, FilesystemEntry } from './filesystem'; @@ -271,3 +271,16 @@ export function uncache(archivePath: string) { export function uncacheAll() { disk.uncacheAll(); } + +export default { + createPackage, + createPackageWithOptions, + createPackageFromFiles, + statFile, + getRawHeader, + listPackage, + extractFile, + extractAll, + uncache, + uncacheAll, +}; diff --git a/tsconfig.json b/tsconfig.json index 0833e88..9e5b08d 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -15,7 +15,8 @@ "moduleResolution": "node", "declaration": true, "noImplicitAny": true, - "strictNullChecks": true + "strictNullChecks": true, + "esModuleInterop": true }, "include": [ "src" From 5f23666403dcbc70578a144a9af0579a19ac5c8d Mon Sep 17 00:00:00 2001 From: Felix Rieseberg Date: Tue, 10 Sep 2024 16:56:10 -0700 Subject: [PATCH 2/2] test: Add a test for default export --- test/api-spec.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/api-spec.js b/test/api-spec.js index db01989..892e814 100644 --- a/test/api-spec.js +++ b/test/api-spec.js @@ -160,4 +160,12 @@ describe('api', function () { ); return compDirs('test/input/packthis-object-prototype/', 'tmp/packthis-object-prototype'); }); + it('should export all functions also in the default export', () => { + const topLevelFunctions = Object.keys(asar).filter((key) => typeof asar[key] === 'function'); + const defaultExportFunctions = Object.keys(asar.default).filter( + (key) => typeof asar.default[key] === 'function', + ); + + assert.deepStrictEqual(topLevelFunctions, defaultExportFunctions); + }); });