-
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathinitLocalMode.js
More file actions
37 lines (32 loc) · 1.21 KB
/
Copy pathinitLocalMode.js
File metadata and controls
37 lines (32 loc) · 1.21 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
const fs = require('fs');
const path = require('path');
const https = require('https');
const root = process.cwd();
const repoBase = 'https://raw.githubusercontent.com/cortexrd/Knack-Toolkit-Library/dev';
const files = [
{ remote: 'KTL.js', local: 'Lib\\KTL\\KTL.js' },
{ remote: 'KTL.css', local: 'Lib\\KTL\\KTL.css' },
{ remote: 'KTL_Defaults.js', local: 'Lib\\KTL\\KTL_Defaults.js' },
{ remote: 'FileServer.bat', local: 'Lib\\KTL\\FileServer.bat' },
{ remote: 'NodeJS/NodeJS_FileServer.js', local: 'Lib\\KTL\\NodeJS\\NodeJS_FileServer.js' }
];
fs.mkdirSync(path.join(root, 'KnackApps'), { recursive: true });
fs.mkdirSync(path.join(root, 'Lib\\KTL\\NodeJS'), { recursive: true });
function download(url, dest) {
return new Promise((resolve, reject) => {
const file = fs.createWriteStream(dest);
https.get(url, res => {
res.pipe(file);
file.on('finish', () => { file.close(resolve); });
}).on('error', reject);
});
}
(async () => {
for (const file of files) {
const url = `${repoBase}/${file.remote}`;
const dest = path.join(root, file.local);
console.log(`Downloading: ${path.basename(file.local)}`);
await download(url, dest);
}
console.log('\nKTL setup complete!');
})();