-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpostbuild-checks.js
More file actions
46 lines (40 loc) · 1.16 KB
/
postbuild-checks.js
File metadata and controls
46 lines (40 loc) · 1.16 KB
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
43
44
45
46
const { promises: fs } = require('fs');
const jpex = require('./dist/cjs/vue-jpex');
const expectedFiles = [
'dist/cjs/vue-jpex.js',
'dist/es/vue-jpex.js',
'dist/ts/index.d.ts',
];
const expectedExports = [
['useJpex', '[object Function]'],
['useResolve', '[object Function]'],
['useProvide', '[object Function]'],
['useRegister', '[object Function]'],
['encase', '[object Function]'],
];
const run = async () => {
// eslint-disable-next-line no-plusplus
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}`);
}
}
// eslint-disable-next-line no-plusplus
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();