-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpostbuild-checks.js
42 lines (36 loc) · 998 Bytes
/
postbuild-checks.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
40
41
42
const { promises: fs } = require('fs');
const jpex = require('./dist/cjs/jpex');
const expectedFiles = [
'dist/cjs/jpex.js',
'dist/es/jpex.js',
'dist/ts/index.d.ts',
'dist/ts/types/index.d.ts',
];
const expectedExports = [
['default', '[object Object]'],
['jpex', '[object Object]'],
];
const run = async () => {
for (let i = 0; i < expectedFiles.length; i++) {
const target = expectedFiles[i];
try {
await fs.stat(target);
} catch (e) {
throw new Error(`Unable to verify file ${target}`);
}
}
for (let i = 0; i < expectedExports.length; i++) {
const [key, type] = expectedExports[i];
if (jpex[key] === void 0) {
throw new Error(`${key} was not exported`);
}
const actualType = Object.prototype.toString.call(jpex[key]);
if (actualType !== type) {
throw new Error(
`Expected type of ${key} to be ${type} but it was ${actualType}`,
);
}
}
console.log('Everything looks good to me');
};
run();