refactor(extract-js): more stable at first download of Luciole

This commit is contained in:
Jérémy Dufraisse 2023-03-14 08:42:15 +01:00
parent 7e0717491f
commit 1d0aa5ac9e

View File

@ -116,23 +116,7 @@ const http = require('http');
let src = 'node_modules/Luciole/' let src = 'node_modules/Luciole/'
let currentPath = path.join(basePath, src) const importLucioleFont = () => {
if (!fs.existsSync(currentPath)) {
fs.mkdirSync(currentPath,{recursive :true})
}
const zipPath = path.join(currentPath,'Luciole_webfonts.zip')
const file = fs.createWriteStream(zipPath)
const request = http.get("http://www.luciole-vision.com/Fichiers/Luciole_webfonts.zip", function(response) {
response.pipe(file)
response.on('end', () => {
setTimeout(()=>{
var AdmZip = require("adm-zip")
var zip = new AdmZip(zipPath)
zip.extractAllTo(/*target path*/ currentPath, /*overwrite*/ true)
},500)
})
});
copySync( copySync(
'node_modules/Luciole/Luciole_webfonts/Read Me.txt', 'node_modules/Luciole/Luciole_webfonts/Read Me.txt',
'fonts/vendor/Luciole/Read Me.txt', 'fonts/vendor/Luciole/Read Me.txt',
@ -186,6 +170,25 @@ fs.writeFileSync(
), ),
css css
) )
}
let currentPath = path.join(basePath, src)
if (!fs.existsSync(currentPath)) {
fs.mkdirSync(currentPath,{recursive :true})
}
const zipPath = path.join(currentPath,'Luciole_webfonts.zip')
const file = fs.createWriteStream(zipPath)
const request = http.get("http://www.luciole-vision.com/Fichiers/Luciole_webfonts.zip", function(response) {
response.pipe(file)
response.on('end', () => {
setTimeout(()=>{
var AdmZip = require("adm-zip")
var zip = new AdmZip(zipPath)
zip.extractAllTo(/*target path*/ currentPath, /*overwrite*/ true)
importLucioleFont()
},500)
})
});
// example // example