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

feat/test-less-compiled
dufraissejeremy 2 years ago
parent 7e0717491f
commit 1d0aa5ac9e
  1. 37
      js/extract-files-from-node-modules.js

@ -116,23 +116,7 @@ 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)
})
});
const importLucioleFont = () => {
copySync(
'node_modules/Luciole/Luciole_webfonts/Read Me.txt',
'fonts/vendor/Luciole/Read Me.txt',
@ -186,6 +170,25 @@ fs.writeFileSync(
),
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

Loading…
Cancel
Save