mirror of
https://github.com/bs-community/blessing-skin-server.git
synced 2024-12-21 06:19:38 +08:00
37 lines
999 B
JavaScript
37 lines
999 B
JavaScript
const fs = require('fs');
|
|
const archiver = require('archiver');
|
|
const { version } = require('../package.json');
|
|
|
|
module.exports = function () {
|
|
const list = fs.readFileSync('./zip.txt', 'utf-8').split('\n');
|
|
list.pop(); // Remove the empty line
|
|
|
|
const output = fs.createWriteStream(`../blessing-skin-server-v${version}.zip`);
|
|
const archive = archiver('zip', { zlib: { level: 9 } });
|
|
|
|
return new Promise((resolve, reject) => {
|
|
output.on('close', resolve);
|
|
archive.on('warning', reject);
|
|
archive.on('error', reject);
|
|
|
|
archive.pipe(output);
|
|
|
|
list.forEach(item => {
|
|
if (item.endsWith('/')) {
|
|
archive.directory(item, item);
|
|
} else {
|
|
archive.file(item, { name: item });
|
|
}
|
|
});
|
|
|
|
archive.glob('storage/**/*.*', {
|
|
dot: true,
|
|
ignore: [
|
|
'storage/textures/*',
|
|
],
|
|
});
|
|
|
|
archive.finalize();
|
|
});
|
|
};
|