-
Notifications
You must be signed in to change notification settings - Fork 4
Plugins
If you've created an extension that you love, you can share it with others by making it into a plugin.
First create a new directory for your plugin to live in:
mkdir chainy-plugin-myplugin
cd chainy-plugin-mypluginUse the Chainy CLI to scaffold the structure of your plugin (it will ask you a few questions):
chainy create-pluginInside lib/yourPluginName.js convert your extension from something that looks like this:
// using the `action` API call to execute an unnamed action
require('chainy').create()
.action(function(currentValue, newValue){
return newValue
})
// or via using the `addExtension` API call to define an action extension called `set`
require('chainy').create()
.addExtension('set', 'action', function(currentValue, newValue){
return newValue
})Into something that looks like this:
module.exports = function(currentValue, newValue){
return newValue
}
module.exports.extensionType = 'action'
module.exports.extensionOptions = {} // optionalIf you would like to export something else as the top level export and not the extension method, you can do this by exporting an extension object instead like so:
module.exports = 'something else'
module.exports.extension = {
method: function(currentValue, newValue){
return newValue
},
type: 'action'
}If you used chainy create-plugin to create your plugin, you can use cake publish to publish your plugin to the npm registry as well as git tag it among other nifty things.
If you didn't use our awesome chainy create-plugin command to create your plugin, you can just use the standard npm publish call instead.
Navigate using the sidebar on the right.
This wiki content is:
Copyright 2014+ Bevry Pty Ltd
Permissively licensed under the Creative Commons Attribution 4.0 International License