TelluIoT / ThingML

The ThingML modelling language
https://github.com/TelluIoT/ThingML
Apache License 2.0
101 stars 32 forks source link

Support for the nodejs_package annotation #252

Closed fungiboletus closed 5 years ago

fungiboletus commented 5 years ago

Summary of the change

The main.js generated file is modified to allow the initialisation of the thingmodel in an exported function. The most visible changes are the builder.append converted to main.append.

Then, the terminate code is put in a function terminate() so it can be exported or called in the SIGINT handler.

The SIGINT handler is modified to check whether it can run (it can't on web browsers with browersify) and it is present only when the nodejs_package annotation is not present.

Finally, if the configuration contains the nodejs_package flag/annotation, an object is returned with an object of instances and the terminate function.

This should work okay.

fungiboletus commented 5 years ago

About the whitespaces changes, I don't even know if I pushed tabs instead of spaces or vis-versa. This is annoying.