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,4 @@
|
||||
module.exports = function (msg, exception) {
|
||||
process.stdout.write('\n[完整性检验] ERROR! ' + msg + '\n');
|
||||
throw new Error(exception);
|
||||
};
|
||||
@@ -0,0 +1,32 @@
|
||||
var helpers = require('./');
|
||||
|
||||
module.exports = function (platform, fileName) {
|
||||
var path = require('path');
|
||||
var fs = require('fs');
|
||||
var cordovaUtil = this.requireCordovaModule('cordova-lib/src/cordova/util');
|
||||
var projectRoot = cordovaUtil.isCordova();
|
||||
var platformPath = path.join(projectRoot, 'platforms', platform);
|
||||
var sourceFile;
|
||||
var content;
|
||||
|
||||
if (platform === 'android') {
|
||||
var fileBasename = fileName;
|
||||
var filePath = 'com/cescit/integrity/' + fileBasename + '.java';
|
||||
try {
|
||||
sourceFile = path.join(platformPath, 'app/src/main/java', filePath);
|
||||
content = fs.readFileSync(sourceFile, 'utf-8');
|
||||
} catch (_e) {
|
||||
try {
|
||||
sourceFile = path.join(platformPath, 'src', filePath);
|
||||
content = fs.readFileSync(sourceFile, 'utf-8');
|
||||
} catch (e) {
|
||||
helpers.exit('Unable to read java class source at path ' + sourceFile, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
content: content,
|
||||
path: sourceFile
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,5 @@
|
||||
module.exports = function () {
|
||||
return (this.opts.platforms || this.opts.cordova.platforms || []).filter(function (platform) {
|
||||
return this.opts.plugin.pluginInfo.getPlatformsArray().indexOf(platform) > -1;
|
||||
}, this);
|
||||
};
|
||||
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* Exit script with custom error log.
|
||||
* @param {string} msg - Error message.
|
||||
* @param {Error} exception
|
||||
*/
|
||||
exports.exit = require('./error_exit');
|
||||
|
||||
/**
|
||||
* Get the real list of platforms affected by a running plugin hook.
|
||||
* @param {Object} context - Cordova context.
|
||||
*/
|
||||
exports.getPlatformsList = invokeHelper.bind(null, './get_platforms_list');
|
||||
|
||||
/**
|
||||
* Detect if the context process is running with verbose option.
|
||||
* @param {Object} context - Cordova context.
|
||||
*/
|
||||
exports.isVerbose = invokeHelper.bind(null, './is_verbose');
|
||||
|
||||
exports.getFileMapContent = invokeHelper.bind(null, './getFileMapContent');
|
||||
|
||||
function invokeHelper (path) {
|
||||
var helper = require(path);
|
||||
var context = arguments[1];
|
||||
return helper.apply(context, Array.prototype.splice.call(arguments, 2));
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
module.exports = function () {
|
||||
return this.opts && this.opts.options && this.opts.options.verbose ||
|
||||
typeof this.cmdLine === 'string' && this.cmdLine.indexOf(' -verbose') > -1;
|
||||
};
|
||||
Reference in New Issue
Block a user