-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
41 lines (33 loc) · 1.12 KB
/
Copy pathindex.js
File metadata and controls
41 lines (33 loc) · 1.12 KB
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
35
36
37
38
39
40
41
const fs = require('fs');
const path = require('path');
const minify = require('minify');
const https = require('https');
https.get('https://raw.githubusercontent.com/kiipy/whatt/master/build/whatt.min.js', (response) => {
var data = '';
response.on('data', (chunk) => {
data += chunk;
});
response.on('end', () => {
writeFiles(createBundle(data));
});
}).on('error', (error) => {
console.log('Error: ' + error.message);
});
const createBundle = (library) => {
var bundle = 'var client = (function(){';
bundle += library + '\n\n';
for (const file of fs.readdirSync('./src')) {
bundle += fs.readFileSync(path.join(__dirname, `/src/${file}`)) + '\n\n';
}
bundle += 'return client; })();';
return bundle;
}
const writeFiles = (bundle) => {
fs.mkdir(path.join(__dirname, '/build/'), () => {
fs.writeFile(path.join(__dirname, '/build/walang.js'), bundle, () => {
minify('./build/walang.js').then((bundle_minified) => {
fs.writeFileSync(path.join(__dirname, '/build/walang.min.js'), bundle_minified)
});
});
});
}