mirror of
https://github.com/en-lwj/cordova-plugin-cescit-integrity.git
synced 2026-04-17 00:04:16 +08:00
[add]添加cordova完整性检验
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
var helpers = require('./helpers');
|
||||
|
||||
module.exports = function (context) {
|
||||
var fs = require('fs');
|
||||
var fileList = ['AssetsIntegrity', 'ResIntegrity', 'ApkIntegrity'];
|
||||
process.stdout.write('[完整性检验] Clearing assets hash from previous build\n');
|
||||
|
||||
helpers.getPlatformsList(context).forEach(function (platform) {
|
||||
fileList.forEach(fileName => {
|
||||
var source = helpers.getFileMapContent(context, platform, fileName);
|
||||
var content = source.content;
|
||||
|
||||
let regexp = ''
|
||||
if(fileName == 'AssetsIntegrity') regexp = /hashList\s*=.+\s*new.*(\(\d+\)[^\w]*)\);/
|
||||
else if(fileName == 'ResIntegrity') regexp = /hashList\s*=.+\s*new.*(\(\d+\)[^\w]*)\);/
|
||||
else if(fileName == 'ApkIntegrity') regexp = /hashList\s*=.+\s*new.*(\(\d+\)[^\w]*)\);/
|
||||
content = source.content.replace(/\s*put\("[^"]+",\s"[^"]{64}"\);/g, '')
|
||||
.replace(regexp, function (match, group) {
|
||||
return match.replace(group, '()\n ');
|
||||
});
|
||||
try {
|
||||
fs.writeFileSync(source.path, content, 'utf-8');
|
||||
} catch (e) {
|
||||
helpers.exit('Unable to write java class source at path ' + source.path, e);
|
||||
}
|
||||
})
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user