Skip to content

Commit 06312cd

Browse files
fix: Export a "default" property (#325)
* fix: Export a "default" property * test: Add a test for default export
1 parent 4f7abe9 commit 06312cd

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

src/asar.ts

+14-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as path from 'path';
2-
import * as minimatch from 'minimatch';
2+
import minimatch from 'minimatch';
33

44
import fs from './wrapped-fs';
55
import { Filesystem, FilesystemEntry } from './filesystem';
@@ -271,3 +271,16 @@ export function uncache(archivePath: string) {
271271
export function uncacheAll() {
272272
disk.uncacheAll();
273273
}
274+
275+
export default {
276+
createPackage,
277+
createPackageWithOptions,
278+
createPackageFromFiles,
279+
statFile,
280+
getRawHeader,
281+
listPackage,
282+
extractFile,
283+
extractAll,
284+
uncache,
285+
uncacheAll,
286+
};

test/api-spec.js

+8
Original file line numberDiff line numberDiff line change
@@ -160,4 +160,12 @@ describe('api', function () {
160160
);
161161
return compDirs('test/input/packthis-object-prototype/', 'tmp/packthis-object-prototype');
162162
});
163+
it('should export all functions also in the default export', () => {
164+
const topLevelFunctions = Object.keys(asar).filter((key) => typeof asar[key] === 'function');
165+
const defaultExportFunctions = Object.keys(asar.default).filter(
166+
(key) => typeof asar.default[key] === 'function',
167+
);
168+
169+
assert.deepStrictEqual(topLevelFunctions, defaultExportFunctions);
170+
});
163171
});

tsconfig.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
"moduleResolution": "node",
1616
"declaration": true,
1717
"noImplicitAny": true,
18-
"strictNullChecks": true
18+
"strictNullChecks": true,
19+
"esModuleInterop": true
1920
},
2021
"include": [
2122
"src"

0 commit comments

Comments
 (0)