mirror of https://github.com/keeweb/keeweb.git
desktop archive validation on build
This commit is contained in:
parent
a8b9293453
commit
72bf952717
|
@ -348,6 +348,14 @@ module.exports = function(grunt) {
|
|||
options: { archive: 'dist/desktop/UpdateDesktop.zip' },
|
||||
files: [{ cwd: 'tmp/desktop/app', src: '**', expand: true }]
|
||||
}
|
||||
},
|
||||
'validate-desktop-update': {
|
||||
desktop: {
|
||||
options: {
|
||||
file: 'dist/desktop/UpdateDesktop.zip',
|
||||
expected: ['main.js', 'app.js', 'index.html', 'package.json', 'node_modules/node-stream-zip/node_stream_zip.js']
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -376,6 +384,7 @@ module.exports = function(grunt) {
|
|||
'copy:desktop_app_content',
|
||||
'string-replace:desktop_html',
|
||||
'compress:desktop_update',
|
||||
'validate-desktop-update',
|
||||
'electron',
|
||||
'electron_builder',
|
||||
'compress:linux',
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
'use strict';
|
||||
|
||||
module.exports = function (grunt) {
|
||||
grunt.registerMultiTask('validate-desktop-update', 'Validates desktop update package', function () {
|
||||
var path = require('path');
|
||||
var done = this.async();
|
||||
var StreamZip = require(path.resolve(__dirname, '../../electron/node_modules/node-stream-zip'));
|
||||
var zip = new StreamZip({ file: this.options().file, storeEntries: true });
|
||||
var expFiles = this.options().expected;
|
||||
zip.on('error', function(err) {
|
||||
grunt.warn(err);
|
||||
});
|
||||
zip.on('ready', function() {
|
||||
var valid = true;
|
||||
expFiles.forEach(function(entry) {
|
||||
try {
|
||||
if (!zip.entryDataSync(entry)) {
|
||||
grunt.warn('Corrupted entry in desktop update archive: ' + entry);
|
||||
valid = false;
|
||||
}
|
||||
} catch (e) {
|
||||
grunt.warn('Entry not found in desktop update archive: ' + entry);
|
||||
valid = false;
|
||||
}
|
||||
});
|
||||
if (valid) {
|
||||
done();
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
Loading…
Reference in New Issue