Add zip script
This commit is contained in:
parent
cea2d3f0ca
commit
1e2bfd02ce
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -4,3 +4,4 @@ pull_locales_login.rb
|
|||
node_modules/
|
||||
package-lock.json
|
||||
yarn.lock
|
||||
*.zip
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
"repository": "openstyles/stylus",
|
||||
"author": "Stylus Team",
|
||||
"devDependencies": {
|
||||
"archiver": "^2.1.1",
|
||||
"codemirror": "^5.39.2",
|
||||
"eslint": "^5.1.0",
|
||||
"fs-extra": "^7.0.0",
|
||||
|
@ -21,6 +22,7 @@
|
|||
"build": "npm run update && npm run build:cm",
|
||||
"build:cm": "node tools/update-libraries.js && node tools/update-codemirror-themes.js",
|
||||
"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
59
tools/zip.js
Normal 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;
|
||||
});
|
Loading…
Reference in New Issue
Block a user