2018-07-21 17:58:54 +00:00
|
|
|
#!/usr/bin/env node
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const fs = require('fs');
|
|
|
|
const archiver = require('archiver');
|
|
|
|
|
2021-01-01 14:27:58 +00:00
|
|
|
function createZip() {
|
|
|
|
const fileName = 'stylus.zip';
|
2020-10-22 19:16:55 +00:00
|
|
|
const ignore = [
|
2018-07-21 17:58:54 +00:00
|
|
|
'.*', // dot files/folders (glob, not regexp)
|
2018-07-23 16:24:38 +00:00
|
|
|
'node_modules/**',
|
|
|
|
'tools/**',
|
2018-07-21 17:58:54 +00:00
|
|
|
'package.json',
|
2018-07-23 16:24:38 +00:00
|
|
|
'package-lock.json',
|
|
|
|
'yarn.lock',
|
2019-11-05 19:30:45 +00:00
|
|
|
'*.zip',
|
2020-11-18 11:17:15 +00:00
|
|
|
'*.map',
|
2018-07-21 17:58:54 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
const file = fs.createWriteStream(fileName);
|
|
|
|
const archive = archiver('zip');
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
archive.on('finish', () => {
|
|
|
|
resolve();
|
|
|
|
});
|
|
|
|
archive.on('warning', err => {
|
|
|
|
if (err.code === 'ENOENT') {
|
|
|
|
console.log('\x1b[33m%s\x1b[0m', 'Warning', err.message);
|
|
|
|
} else {
|
|
|
|
reject();
|
|
|
|
throw err;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
archive.on('error', err => {
|
|
|
|
reject();
|
|
|
|
throw err;
|
|
|
|
});
|
|
|
|
|
|
|
|
archive.pipe(file);
|
2021-12-12 15:14:31 +00:00
|
|
|
archive.glob('dist/**', {ignore});
|
2018-07-21 17:58:54 +00:00
|
|
|
archive.finalize();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-10-22 19:16:55 +00:00
|
|
|
(async () => {
|
|
|
|
try {
|
|
|
|
await createZip();
|
|
|
|
console.log('\x1b[32m%s\x1b[0m', 'Stylus zip complete');
|
|
|
|
} catch (err) {
|
|
|
|
console.error(err);
|
|
|
|
process.exit(1);
|
|
|
|
}
|
|
|
|
})();
|