Inventables Community Forum

Using nodejs to ease code development

The built in text editor for app development is fine for writing small apps, but on a larger app, the lack of standard text editor functions to help with, say, code refactoring can be a pain. Although this is in no way a perfect alternative, it does allow quite a bit of development outside of the editor. It will still be necessary to paste the code back into the editor window to use the app with Easel.

I had never used nodejs before, I found this helpful in figuring this out.

  1. Install nodejs and make sure you can run it from a command window.

  2. Copy your code into a file. I’ve attached an example file called “jsundertest.js”

  3. Modify this js file and add this code to the top of it

    exports.test= function(args, success, failure) {

  4. If necessary modify the attached main.js to set any needed parameters and to match your javascript file name.

  5. run nodejs with the main.js as an argument e.g. “node main.js”.

  6. If successful, there should be a file called output.svg . This file is a standard SVG, and can be imported into Easel, or viewed in Inkscape. In Ubuntu, the icon is the rendered image making seeing you changes easy.

Although all of the code could be included in the jsundertest file, I wanted to modify that file as little as possible. You can export whatever functions you want, and I left some code at the end of the main.js commented out that would read a text file and call a function in the test file ( that function not present in the jsundertest file )

Since it does involve copying pasting the code from the Easel app editor into your favorite text editor it isn’t perfect, but hopefully saving the svg file out to view should mean you can do quite a bit of development outside Easel before going back into Easel for final testing etc.

Test wrapper file
main.js (964 Bytes)

Example development code from the basic Easel new app.
jsundertest.js (1.2 KB)

If you find any mistakes in this, please PM me so I can fix them.

1 Like