2020-04-16 18:37:41 +00:00
|
|
|
// This is a JS script so that the directory is created in-process on Windows.
|
2020-04-20 15:46:52 +00:00
|
|
|
// If the script isn't run in-process, there's a risk of it racing or never running
|
|
|
|
// due to file associations in Windows.
|
2020-04-16 18:37:41 +00:00
|
|
|
// Sorry.
|
|
|
|
|
|
|
|
const fs = require("fs");
|
|
|
|
const path = require("path");
|
2023-04-18 16:01:10 +00:00
|
|
|
const { mkdirpSync } = require("mkdirp");
|
2020-04-16 18:37:41 +00:00
|
|
|
const fetch = require("node-fetch");
|
2020-10-16 12:48:28 +00:00
|
|
|
const ProxyAgent = require("simple-proxy-agent");
|
2020-04-16 18:37:41 +00:00
|
|
|
|
|
|
|
console.log("Making webapp directory");
|
2023-04-18 16:01:10 +00:00
|
|
|
mkdirpSync("webapp");
|
2020-04-16 18:37:41 +00:00
|
|
|
|
2022-01-11 16:15:17 +00:00
|
|
|
// curl -s https://meet.element.io/libs/external_api.min.js > ./webapp/jitsi_external_api.min.js
|
2020-04-16 18:37:41 +00:00
|
|
|
console.log("Downloading Jitsi script");
|
|
|
|
const fname = path.join("webapp", "jitsi_external_api.min.js");
|
2020-10-16 12:48:28 +00:00
|
|
|
|
|
|
|
const options = {};
|
|
|
|
if (process.env.HTTPS_PROXY) {
|
2022-01-11 16:15:17 +00:00
|
|
|
options.agent = new ProxyAgent(process.env.HTTPS_PROXY, { tunnel: true });
|
2020-10-16 12:48:28 +00:00
|
|
|
}
|
|
|
|
|
2022-01-11 16:15:17 +00:00
|
|
|
fetch("https://meet.element.io/libs/external_api.min.js", options)
|
|
|
|
.then((res) => {
|
|
|
|
const stream = fs.createWriteStream(fname);
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
res.body.pipe(stream);
|
|
|
|
res.body.on("error", (err) => reject(err));
|
|
|
|
res.body.on("finish", () => resolve());
|
|
|
|
});
|
2020-04-16 18:37:41 +00:00
|
|
|
})
|
|
|
|
.then(() => console.log("Done with Jitsi download"));
|