🐛 App > Fix zip cache
This commit is contained in:
+20
-20
@@ -66,33 +66,33 @@ class Project
|
|||||||
{
|
{
|
||||||
console.log(`${chalk.green.bold('project > zip')} - ${chalk.cyan('from cache')}`)
|
console.log(`${chalk.green.bold('project > zip')} - ${chalk.cyan('from cache')}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.zipBuffer
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
// 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)
|
|
||||||
{
|
{
|
||||||
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
|
// Create a zip file
|
||||||
if(stats.isFile())
|
this.zip = new JSZip()
|
||||||
|
|
||||||
|
// Add files to zip
|
||||||
|
for(const _file of files)
|
||||||
{
|
{
|
||||||
const basename = path.basename(_file)
|
const stats = fs.lstatSync(_file)
|
||||||
const relativePath = _file.replace(basename, '').replace(this.path, '')
|
|
||||||
zip.file(`${relativePath}${basename}`, fs.readFileSync(_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
|
// 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
|
this.zipNeedsUpdate = false
|
||||||
|
|
||||||
// Debug
|
// Debug
|
||||||
@@ -101,7 +101,7 @@ class Project
|
|||||||
console.log(`${chalk.green.bold('project > zip')} - ${chalk.cyan('create')}`)
|
console.log(`${chalk.green.bold('project > zip')} - ${chalk.cyan('create')}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.zipBuffer
|
return zipBuffer
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Add Test contents
|
* Add Test contents
|
||||||
|
|||||||
Reference in New Issue
Block a user