stylus/tools/zip.js

52 lines
1.2 KiB
JavaScript
Raw Permalink Normal View History

2018-07-21 17:58:54 +00:00
#!/usr/bin/env node
'use strict';
const fs = require('fs');
const archiver = require('archiver');
function createZip() {
const fileName = 'stylus.zip';
const exclude = [
'.*', // dot files/folders (glob, not regexp)
'vendor/codemirror/lib/**', // get unmodified copy from node_modules
'node_modules/**',
'tools/**',
2018-07-21 17:58:54 +00:00
'package.json',
'package-lock.json',
'yarn.lock',
2018-07-21 17:58:54 +00:00
'*.zip'
];
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);
archive.glob('**', {ignore: exclude});
// Don't use modified codemirror.js (see "update-libraries.js")
archive.directory('node_modules/codemirror/lib', 'vendor/codemirror/lib');
2018-07-21 17:58:54 +00:00
archive.finalize();
});
}
createZip()
.then(() => console.log('\x1b[32m%s\x1b[0m', 'Stylus zip complete'))
.catch(err => {
throw err;
});