🐛 App > Fix zip cache

This commit is contained in:
brunosimon
2018-11-29 21:56:28 +01:00
parent 2393624d36
commit 8aaa885a54
+20 -20
View File
@@ -66,33 +66,33 @@ class Project
{
console.log(`${chalk.green.bold('project > zip')} - ${chalk.cyan('from cache')}`)
}
return this.zipBuffer
}
// Search files with glob
const globPattern = ['**', ...this.exclude.map((item) => `!${item}`)]
const files = globby.sync(globPattern, { dot: true })
// Create a zip file
const zip = new JSZip()
// Add files to zip
for(const _file of files)
else
{
const stats = fs.lstatSync(_file)
// Search files with glob
const globPattern = ['**', ...this.exclude.map((item) => `!${item}`)]
const files = globby.sync(globPattern, { dot: true })
// Ignore if folder or exluded
if(stats.isFile())
// Create a zip file
this.zip = new JSZip()
// Add files to zip
for(const _file of files)
{
const basename = path.basename(_file)
const relativePath = _file.replace(basename, '').replace(this.path, '')
zip.file(`${relativePath}${basename}`, fs.readFileSync(_file))
const stats = fs.lstatSync(_file)
// Ignore if folder or exluded
if(stats.isFile())
{
const basename = path.basename(_file)
const relativePath = _file.replace(basename, '').replace(this.path, '')
this.zip.file(`${relativePath}${basename}`, fs.readFileSync(_file))
}
}
}
// Create and return zip buffer
this.zipBuffer = zip.generateNodeStream({ type: 'nodebuffer', streamFiles: true })
const zipBuffer = this.zip.generateNodeStream({ type: 'nodebuffer', streamFiles: true })
this.zipNeedsUpdate = false
// Debug
@@ -101,7 +101,7 @@ class Project
console.log(`${chalk.green.bold('project > zip')} - ${chalk.cyan('create')}`)
}
return this.zipBuffer
return zipBuffer
}
/**
* Add Test contents