-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathmakeZip.js
More file actions
32 lines (25 loc) · 754 Bytes
/
makeZip.js
File metadata and controls
32 lines (25 loc) · 754 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
var fs = require('fs');
var archiver = require('archiver');
const slug = 'pm2-modern-plugin';
var output = fs.createWriteStream(`${slug}.zip`);
var archive = archiver('zip');
console.log( 'Zipping!')
output.on('close', function () {
console.log('Zipped!');
console.log(archive.pointer() + ' total bytes');
});
archive.on('error', function(err){
throw err;
});
archive.pipe(output);
archive.append(fs.createReadStream(
__dirname + `/${slug}.php`
), { name: `/${slug}.php` });
//Directories to copy
['classes', 'build', 'vendor/composer'].forEach( ( dir ) => {
archive.directory(dir, '/' + dir);
});
archive.append(fs.createReadStream(
__dirname + '/vendor/autoload.php'
), { name: 'vendor/autoload.php' });
archive.finalize();