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,29 +116,13 @@ const http = require('http');
let src = 'node_modules/Luciole/'
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)
},500)
})
});
copySync(
const importLucioleFont = () => {
copySync(
'node_modules/Luciole/Luciole_webfonts/Read Me.txt',
'fonts/vendor/Luciole/Read Me.txt',
{ overwrite: true }
)
var arr = [
)
var arr = [
{
name:'Luciole-Regular',
style:'normal',
@ -159,9 +143,9 @@ var arr = [
style:'italic',
weight:'bold'
}
]
let css = "/* Webfont: Luciole */\n\n"
arr.forEach((data)=>{
]
let css = "/* Webfont: Luciole */\n\n"
arr.forEach((data)=>{
let name = data.name
copySync(
`node_modules/Luciole/Luciole_webfonts/${name}/${name}.woff`,
@ -178,14 +162,33 @@ arr.forEach((data)=>{
text-rendering: optimizeLegibility;
}
`
})
fs.writeFileSync(
})
fs.writeFileSync(
path.join(
basePath,
'fonts/vendor/Luciole/Luciole.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