forked from Dogfalo/materialize
-
-
Notifications
You must be signed in to change notification settings - Fork 106
/
Copy pathcompress.js
35 lines (27 loc) · 940 Bytes
/
compress.js
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
33
34
35
import fs from 'fs';
import archiver from 'archiver';
const packageJson = JSON.parse(fs.readFileSync('./package.json').toString());
const version = packageJson.version;
function compressToZip(name, withSrc = false) {
const output = fs.createWriteStream(name);
const archive = archiver('zip');
output.on('close', function () {
console.log(archive.pointer() + ' total bytes');
console.log('archiver has been finalized and the output file descriptor has closed.');
});
archive.on('error', function (err) {
throw err;
});
archive.pipe(output);
archive.directory('dist/js/', 'js');
archive.directory('dist/css/', 'css');
if (withSrc) {
archive.directory('src/');
archive.directory('sass/');
}
archive.file('LICENSE');
archive.file('README.md');
archive.finalize();
}
compressToZip('dist/materialize-v' + version + '.zip');
compressToZip('dist/materialize-src-v' + version + '.zip', true);