forked from BenGWeeks/Zapp.ie
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.js
32 lines (26 loc) · 1 KB
/
build.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
const fs = require('fs');
const path = require('path');
// Read environment variables
const contentUrl = process.env.CONTENT_URL;
const websiteUrl = process.env.WEBSITE_URL;
// Check for missing environment variables
if (!contentUrl || !websiteUrl) {
console.error('Error: CONTENT_URL and WEBSITE_URL environment variables must be set.');
process.exit(1);
}
try {
// Read the template file
const templatePath = path.join(__dirname, 'manifest.template.json');
const template = fs.readFileSync(templatePath, 'utf8');
// Replace placeholders with environment variables
const manifest = template
.replace(/{{CONTENT_URL}}/g, contentUrl)
.replace(/{{WEBSITE_URL}}/g, websiteUrl);
// Write the final manifest.json file
const outputPath = path.join(__dirname, 'appPackage','manifest.json');
fs.writeFileSync(outputPath, manifest, 'utf8');
console.log('manifest.json has been generated successfully.');
} catch (error) {
console.error('Error generating manifest.json:', error);
process.exit(1);
}