element-web/scripts/build-jitsi.ts

31 lines
1.1 KiB
TypeScript
Raw Normal View History

// This is a JS script so that the directory is created in-process on Windows.
// If the script isn't run in-process, there's a risk of it racing or never running
// due to file associations in Windows.
// Sorry.
2023-08-18 09:34:56 +02:00
import * as fs from "node:fs";
import * as path from "node:path";
import { mkdirpSync } from "mkdirp";
import fetch from "node-fetch";
import { ProxyAgent } from "proxy-agent";
console.log("Making webapp directory");
mkdirpSync("webapp");
// curl -s https://meet.element.io/libs/external_api.min.js > ./webapp/jitsi_external_api.min.js
console.log("Downloading Jitsi script");
const fname = path.join("webapp", "jitsi_external_api.min.js");
2023-08-18 09:34:56 +02:00
fetch("https://meet.element.io/libs/external_api.min.js", {
agent: new ProxyAgent(),
})
2022-12-09 13:28:29 +01:00
.then((res) => {
const stream = fs.createWriteStream(fname);
2023-08-18 09:34:56 +02:00
return new Promise<void>((resolve, reject) => {
2022-12-09 13:28:29 +01:00
res.body.pipe(stream);
res.body.on("error", (err) => reject(err));
res.body.on("finish", () => resolve());
});
})
.then(() => console.log("Done with Jitsi download"));