forked from enricoros/big-AGI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate-private-msg.js
34 lines (28 loc) · 990 Bytes
/
generate-private-msg.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
// generate-config.js
const fs = require('fs');
const path = require('path');
const fetch = require('node-fetch');
const outputPath = path.join('src', 'modules', 'aifn', 'bigquery', 'symb-message.ts');
async function fetchGistContent(gistUrl) {
const response = await fetch(gistUrl);
if (!response.ok) {
throw new Error(`Gist fetch failed: ${response.statusText}`);
}
return response.text();
}
async function generateConfig() {
let content;
// When running on Netlify, fetch the content from the Gist
const gistUrl = process.env.SYMB_MESSAGE_GIST_URL;
if (!gistUrl) {
console.warn('\nWARNING: Environment variable SYMB_MESSAGE_GIST_URL is not set. Skipping generation of symb-message.ts.\n');
return;
}
content = await fetchGistContent(gistUrl);
// Write the content to the file used in the build
fs.writeFileSync(outputPath, content);
}
generateConfig().catch((error) => {
console.error(error);
process.exit(1); // Exit with a failure code
});