Inspired by @Apple
And very thankful for his insights and ideas I just released a custom extension for nodejs to run custom js code without having to create a custom module or a formatter.
Sometimes for small quick things you just don’t want to go through the hassle of creating a full extension for a very specific thing that could be easily achieved in a few seconds of writing some JS code.
There are also other cases where a custom extension will serve the purpose for a very specific case but if there is a small variation on the logic you need to build another module i.e. map() function.
The following SC action:
Will return:
In the code
field you add the JS code you want to execute and in the data
grid you define the variables and their Server Connect bindings you need to pass to your script if you need them. The SC action will return the last statement executed in the code field.
Update 1.1.0
- Remove the option to bind data to the code field
- Add a timeout option to allow ending the execution if it takes longer than the specified limit
- Added a checkbox to toggle if errors should be logged in the console or not
- There was a bug with the output checkbox that defaulted to true but wasn’t working. Now it defaults to false
- Icon changes
Update 1.2.0
Breaking Change
- Due to wrapping the custom code in an IIFE you need to explicitly return something so it shows in the output i.e.
return 'hello world'
Added
- IIFE wrapper. Wrapped the custom code in an IIFE to improve performance of vm.
- Forward console. You can now use console object functions i.e.
console.log()
in your code and the output will be forwarded to the server console. - UI changes
Fixed
- Fixed initial values of several checkboxes in the UI
As always PRs are welcome to improve the extension and squash bugs
Last updated: