Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemathinc
GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/cdn/postinstall.js
1447 views
1
#!/usr/bin/env node
2
3
console.log("Ensuring versioned symlinks exist.");
4
5
let versions;
6
7
try {
8
({ versions } = require("./dist/index.js"));
9
} catch (err) {
10
// versions info doesn't exist yet, e.g., when doing an initial "npm ci".
11
process.exit(0);
12
}
13
14
const { statSync, symlinkSync } = require("fs");
15
16
for (const pkg in versions) {
17
const path = `dist/${pkg}-${versions[pkg]}`;
18
try {
19
// stat to see if path exists
20
statSync(path);
21
} catch (_) {
22
// it does not, so make link
23
console.log(`${path} --> ${pkg}`);
24
symlinkSync(pkg, path);
25
}
26
}
27
28