Open tomalex0 opened 8 years ago
Hey @tomalex0 you could just export a function, which returns the getStatus
function as an object, which would have access to the config object. Would be something like:
module.exports = (config) => {
return {
getStatus() {
// at this point I have access to the "config" object
return true;
}
};
};
module.exports = function spec() {
return {
/**
*
* @param config
* @param next
*/
onconfig: function(config, next) {
//Initiate Utility Function with config
const util = require('./utility')(config);
var status = util.getStatus(); // true
// at this point you could also merge the resulting value from `util.getStatus` to the current kraken configuration by calling config.use({ status });
next(null, config);
}
};
};
@jonathansamines thanks for the response, let me give this a try
I'm looking for an option to get config value in exec handler function, below one i tried but
exec:./lib/utility#getStatus
get triggered first and config value will be undefined and might be the expected behavior , is there any alternative approach?First i was looking into option like this https://github.com/krakenjs/kraken-js/issues/316 . For this i need to write custom shortstop handler and not sure how to do that in existing kraken setup.
Please let me know if you have any suggestions or solution .
config.json
utility.js
spec.js