-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpostinstall.js
47 lines (45 loc) · 1.04 KB
/
postinstall.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
43
44
45
46
47
import { install, printStats } from "esinstall";
import prettyBytes from "pretty-bytes";
import { options, specs } from "./esinstall.js";
// esinstall doesn't let us quiet the output while it runs
// so we kinda do that here.
const logger = {
debug() {},
warn(...args) {
console.warn(...args);
},
error(...args) {
console.error(...args);
},
};
async function main() {
const { success, stats } = await install(specs, {
dest: "./public/web_modules",
logger,
...options,
});
if (stats) {
console.table(
Object.entries(stats.direct)
.map(([key, value]) => ({
esm: key,
...Object.fromEntries(
Object.entries(value).map(([k, v]) => [k, prettyBytes(v)])
),
}))
.concat(
Object.entries(stats.common).map(([key, value]) => ({
esm: key,
...Object.fromEntries(
Object.entries(value).map(([k, v]) => [k, prettyBytes(v)])
),
}))
)
);
}
}
try {
main();
} catch (e) {
throw e;
}