Add zip script

This commit is contained in:
Rob Garrison 2018-07-20 12:27:33 -05:00
parent cea2d3f0ca
commit 1e2bfd02ce
3 changed files with 63 additions and 1 deletions

1
.gitignore vendored
View File

@ -4,3 +4,4 @@ pull_locales_login.rb
node_modules/ node_modules/
package-lock.json package-lock.json
yarn.lock yarn.lock
*.zip

View File

@ -6,6 +6,7 @@
"repository": "openstyles/stylus", "repository": "openstyles/stylus",
"author": "Stylus Team", "author": "Stylus Team",
"devDependencies": { "devDependencies": {
"archiver": "^2.1.1",
"codemirror": "^5.39.2", "codemirror": "^5.39.2",
"eslint": "^5.1.0", "eslint": "^5.1.0",
"fs-extra": "^7.0.0", "fs-extra": "^7.0.0",
@ -21,6 +22,7 @@
"build": "npm run update && npm run build:cm", "build": "npm run update && npm run build:cm",
"build:cm": "node tools/update-libraries.js && node tools/update-codemirror-themes.js", "build:cm": "node tools/update-libraries.js && node tools/update-codemirror-themes.js",
"lint": "eslint **/*.js || true", "lint": "eslint **/*.js || true",
"update": "updates -u && npm update" "update": "updates -u && npm update",
"zip": "node tools/zip.js"
} }
} }

59
tools/zip.js Normal file
View File

@ -0,0 +1,59 @@
#!/usr/bin/env node
'use strict';
const fs = require('fs');
const archiver = require('archiver');
function createZip() {
const fileName = 'stylus.zip';
const includes = [
'_locales/*',
'background/*',
'content/*',
'edit/*',
'images/*',
'install-usercss/*',
'js/*',
'manage/*',
'msgbox/*',
'options/*',
'popup/*',
'vendor/*',
'vendor-overwrites/*',
'*.html',
'*.css',
'manifest.json',
'LICENSE',
'README.md'
];
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);
includes.forEach(file => archive.glob(file));
archive.finalize();
});
}
createZip()
.then(() => console.log('\x1b[32m%s\x1b[0m', 'Stylus zip complete'))
.catch(err => {
throw err;
});