Skip to content

Commit c9cc0a1

Browse files
toyobayashimalept
andauthored
fix: CreateOptions.transform should return stream or void (#195)
Co-authored-by: Mark Lee <[email protected]>
1 parent 3f243e2 commit c9cc0a1

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

lib/index.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export type CreateOptions = {
66
globOptions?: GlobOptions;
77
ordering?: string;
88
pattern?: string;
9-
transform?: (filePath: string) => string;
9+
transform?: (filePath: string) => NodeJS.ReadWriteStream | void;
1010
unpack?: string;
1111
unpackDir?: string;
1212
};

test/index.test-d.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as asar from '..';
22
import * as fs from 'fs';
3+
import * as crypto from 'crypto'
34
import { expectType } from 'tsd';
45

56
await asar.createPackage('bin', 'tmp/foo.asar');
@@ -8,7 +9,11 @@ await asar.createPackageWithOptions('bin', 'tmp/foo.asar', {
89
globOptions: {
910
debug: true,
1011
},
11-
transform: (filePath: string) => filePath.replace('/', ':'),
12+
transform: (filePath: string) => {
13+
if (process.env.TRANSFORM_ASAR) {
14+
return crypto.createCipheriv('aes-256-cbc', crypto.randomBytes(32), crypto.randomBytes(16)).setAutoPadding(true).setEncoding('base64')
15+
}
16+
}
1217
});
1318
await asar.createPackageFromFiles('bin', 'tmp/foo.asar', ['bin/asar.js']);
1419
const stat = fs.statSync('bin/asar.js');

0 commit comments

Comments
 (0)