forked from sleeyax/asarmor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
39 lines (34 loc) · 997 Bytes
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
require('asar-node').register();
const asar = require('asar');
const {original, protected} = require('./constants');
const fs = require('fs');
function test() {
const archives = [original, protected];
// check if we can still call exported functions
for (const archive of archives) {
const { sum } = require(archive + '/src/sum');
const a = 1;
const b = 1;
console.log(`${archive}: the sum of ${a} + ${b} is still ${sum(a, b)}`);
}
// try to extract the archives
// (trying to extract the protected archive should fail)
let success = 0;
for (const archive of archives) {
try {
asar.extractAll(archive, 'extracted');
success++;
console.log(`${archive}: successfully extracted`);
} catch (ex) {
console.log(`${archive}: failed to extract`);
} finally {
fs.rmSync('extracted', {recursive: true});
}
}
if (success == 1) {
console.log('test succeeded')
} else {
console.warn('test failed');
}
}
test();