-
Notifications
You must be signed in to change notification settings - Fork 123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
allow mocked plugins (for oc dev
) to run code
#129
Comments
👍 {
"registries": ["http://registry.com"],
"mocks": {
"plugins": {
"static": {
"foo": "bar"
}
}
}
} I would suggest something that
{
"registries": ["http://registry.com"],
"mocks": {
"plugins": {
"src": "./mock-plugins.js",
"static": {
"bar": "hello"
}
}
}
} Where the requested file would be a node file with a oc-plugin-style-ish api for register method for each plugin name: module.exports.pluginFoo = [{
name: 'foo',
register: require('oc-foo'), // an actual plugin or a function with the mock
options: { /* some options in case we use the real plugin */}
}, function(err){
if(!!err){
console.log('plugin failed to initialise');
process.exit(1);
}
}]; Another approach would be to have an What do you think? |
I would say we want to keep the plugins enumerated in the oc.json: {
"registries": ["http://registry.com"],
"mocks": {
"plugins": {
"dynamic": {
"plugin1": "./plugin1.js",
"plugin1": "./plugin2.js"
},
"static": {
"bar": "hello"
}
}
}
} Do we need the register function for these plugins? Considering they're supposed to be mocks? Can we keep the signature dead simple: module.exports = function(a){
return a ? "foo" : "bar";
} |
uhm, I actually like this, seems simple and readable 👍 |
good because it took me 10 mins 👍 https://github.com/opentable/oc/compare/mock-plugins-code?expand=1 Just need to update the docs and I'll send a PR |
closed by #130 |
Rather than just returning a static value, it would be nice to have the option to run a function.
The text was updated successfully, but these errors were encountered: