1.0.5 • Published 8 years ago
remi-topmarks-results v1.0.5
Add Results Plugin
A remi extension that adds the addResults method to the app so it can be used by plugins. Designed to specifically make it easier to make Topmarks plugins.
Installation
npm i remi-topmarks-results
Usage
Register the extension in the registration app.
import remi from 'remi';
import remiExpose from 'remi-topmarks-results';
const app = {};
const registrator = remi(app);
registrator.hook(addResults());
registrator.register({register: require('sample-plugin')});
Then plugins can use the addResults
method:
let samplePlugin = (app, options next) => {
// do some stuff and gather the results
app.addResults('foo'); // There's an optional parameter for a timestamp, if none is specified it will default to now.
next();
}
samplePlugin.attributes = {
pkg: require('../package.json')
}
After the plugin has added results, they are accessible on as app.results
. It is an array that will continue to push results when they are added.
When the plugin has url
and/or pageId
properties, they will be included in the results.
As sample result:
[ { plugin: 'plugin', timestamp: 1469770823748, report: 'foo' } ]