Skip to content

Instantly share code, notes, and snippets.

@zachowj
Last active September 11, 2020 16:47
Show Gist options
  • Save zachowj/5536debfdf9d835ed5f4d9615e452c24 to your computer and use it in GitHub Desktop.
Save zachowj/5536debfdf9d835ed5f4d9615e452c24 to your computer and use it in GitHub Desktop.
create a directory inside the node_modules directory named snips place index.js in there
[{"id":"e3bbd992.6544d8","type":"inject","z":"ffbd7f06.4a014","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":170,"y":944,"wires":[["5e7064be.6a665c"]]},{"id":"e32fd63f.6e1c38","type":"debug","z":"ffbd7f06.4a014","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":486,"y":944,"wires":[]},{"id":"5e7064be.6a665c","type":"function","z":"ffbd7f06.4a014","name":"","func":"const snips = global.get(\"snips\");\nmsg.payload = snips.add(1,2);\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":330,"y":944,"wires":[["e32fd63f.6e1c38"]]}]
module.exports = {
add(x, y) {
return x + y;
}
}
// Add this to the node-red settings.js
// ...
functionGlobalContext: {
// os:require('os'),
// octalbonescript:require('octalbonescript'),
// jfive:require("johnny-five"),
// j5board:require("johnny-five").Board({repl:false})
snips:require("snips")
},
//...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment