-
Notifications
You must be signed in to change notification settings - Fork 1
/
file-downloader.js
49 lines (47 loc) · 1.39 KB
/
file-downloader.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
const { https } = require('follow-redirects')
const fs = require('fs')
const downloads = [
{
filePath: './src/styles/graphiql.css',
url: 'https://unpkg.com/[email protected]/graphiql.min.css'
},
{
filePath: './public/fonts/material-icons.ttf',
url:
'https://fonts.gstatic.com/s/materialicons/v76/flUhRq6tzZclQEJ-Vdg-IuiaDsNZ.ttf'
},
{
filePath: './public/fonts/material-icons-outlined.otf',
url:
'https://fonts.gstatic.com/s/materialiconsoutlined/v44/gok-H7zzDkdnRel8-DQ6KAXJ69wP1tGnf4ZGhUcd.otf'
},
{
filePath: './public/fonts/roboto-100.ttf',
url: 'https://fonts.gstatic.com/s/roboto/v20/KFOkCnqEu92Fr1MmgWxP.ttf'
},
{
filePath: './public/fonts/roboto-300.ttf',
url: 'https://fonts.gstatic.com/s/roboto/v20/KFOlCnqEu92Fr1MmSU5vAw.ttf'
},
{
filePath: './public/fonts/roboto-400.ttf',
url: 'https://fonts.gstatic.com/s/roboto/v20/KFOmCnqEu92Fr1Me5Q.ttf'
},
{
filePath: './public/fonts/roboto-500.ttf',
url: 'https://fonts.gstatic.com/s/roboto/v20/KFOlCnqEu92Fr1MmEU9vAw.ttf'
},
{
filePath: './public/fonts/roboto-700.ttf',
url: 'https://fonts.gstatic.com/s/roboto/v20/KFOlCnqEu92Fr1MmWUlvAw.ttf'
}
]
downloads.forEach(loc => {
const file = fs.createWriteStream(loc.filePath)
https.get(loc.url, loc.options, function(res) {
res.pipe(file)
file.on('finish', function() {
file.close()
})
})
})