diff options
Diffstat (limited to 'script/package')
-rwxr-xr-x | script/package | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/script/package b/script/package new file mode 100755 index 0000000..07f8bdf --- /dev/null +++ b/script/package @@ -0,0 +1,39 @@ +#!/usr/bin/env node + +const fs = require('fs'); +const path = require('path'); +const manifest = require('../manifest'); +const JSZip = require('jszip'); + +const resources = () => { + return [ + 'manifest.json', + 'resources/disabled_32x32.png', + 'resources/enabled_32x32.png', + manifest.options_ui.page, + 'build/settings.js', + ].concat( + Object.values(manifest.icons), + manifest.background.scripts, + manifest.content_scripts.map(cs => cs.js).reduce((a1, a2) => a1.concat(a2), []), + manifest.web_accessible_resources, + ).sort(); +}; + +const output = `vim-vixen-${manifest.version}.zip` + +let basedir = path.join(__dirname, '..'); +let zip = new JSZip(); + +for (let r of resources()) { + console.log(` adding: ${r}`) + let data = fs.readFileSync(path.join(basedir, r)); + zip.file(r, data); +} + +zip + .generateNodeStream({ type: 'nodebuffer', streamFiles: true }) + .pipe(fs.createWriteStream(output)) + .on('finish', function () { + console.log(`${output} created`); + }); |