@hyperledger/caliper-core
Advanced tools
Comparing version 0.3.1-unstable-20200316171957 to 0.3.1-unstable-20200318134957
@@ -151,2 +151,27 @@ /* | ||
/** | ||
* Check if a named module is installed and accessible by caliper | ||
* @param {string} moduleName the name of the module to check | ||
* @param {Function} requireFunction The "require" function (with appropriate scoping) to use to load the module. | ||
* @returns {boolean} boolean value for existence of accessible package | ||
*/ | ||
static moduleIsInstalled(moduleName, requireFunction = require) { | ||
let modulePath; | ||
if (moduleName.startsWith('./') || moduleName.startsWith('/')) { | ||
// treat it as an external module, but resolve the path, so it's absolute | ||
modulePath = CaliperUtils.resolvePath(moduleName); | ||
} else { | ||
// treat it as a package dependency (user must install it beforehand) | ||
modulePath = moduleName; | ||
} | ||
try { | ||
CaliperUtils.loadModule(modulePath, requireFunction); | ||
return true; | ||
} catch (err) { | ||
// If the module can not be found, an error is thrown | ||
return false; | ||
} | ||
} | ||
/** | ||
* Utility function to check for singleton values | ||
@@ -153,0 +178,0 @@ * @param {string[]} passedArgs arguments passed by user |
{ | ||
"name": "@hyperledger/caliper-core", | ||
"description": "Core Hyperledger Caliper module, used for running performance benchmarks that interact with blockchain technologies", | ||
"version": "0.3.1-unstable-20200316171957", | ||
"version": "0.3.1-unstable-20200318134957", | ||
"repository": { | ||
@@ -6,0 +6,0 @@ "type": "git", |
463847
10362
15