forked from snowplow/snowplow-javascript-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathintegration-template.js
More file actions
26 lines (23 loc) · 817 Bytes
/
Copy pathintegration-template.js
File metadata and controls
26 lines (23 loc) · 817 Bytes
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
const fs = require('fs');
const handlebars = require('handlebars');
const buffer = fs.readFileSync(process.cwd() + '/templates/integration-template.html');
const integrationTemplate = buffer.toString();
const template = handlebars.compile(integrationTemplate);
const subdomain = process.env.SUBDOMAIN;
if (subdomain === undefined) {
console.log('Error: SUBDOMAIN env variable not defined');
}
const context = {
endpoint: subdomain ? subdomain + 'ngrok.io' : '127.0.0.1:8000',
};
const file = template(context);
try {
const data = fs.writeFileSync(process.cwd() + '/templates/filled/integration.html', file);
console.log('integration.html generated and written!');
process.exit(0);
} catch (err) {
console.log('Error occurred, see line below:');
console.log(err);
process.exit(1);
}
process.exit(0);