rwaldron / tessel-io

A Tessel 2 IO Plugin for Johnny-Five JavaScript Robotics programs
http://johnny-five.io
50 stars 11 forks source link

Inform Johnny-Five that it must not create a repl instance if deployed to flash... #8

Closed rwaldron closed 8 years ago

rwaldron commented 8 years ago

By setting:

this.repl = false;

In the Tessel constructor (before emitting "ready"), we can inform Johnny-Five that it must not create a repl instance.

The criteria is:

Assigning to @brianarn

rwaldron commented 8 years ago

Originally discovered here https://github.com/brianarn/t2-rgb-led-rainbow

brianarn commented 8 years ago

I took a couple of stabs at this, and am at an interesting spot:

First, I was looking at process.cwd() but it turns out, that doesn't return what I'd expect.

Then, I switched to __dirname instead, which generally provides what I'd expect:

Under my current detection, under run the REPL will still be available (though in practice, I'm finding that it's not really usable), but under push it turns off, and I've verified this via my t2-rgb-led-rainbow repo as linked above.

However, I'm finding that authoring tests in this environment is difficult, as __dirname is per-module, so I can't easily mock it in any reasonable fashion.

Still trying other things, but wanted to document steps thus far.

rwaldron commented 8 years ago

Make a function that returns __dirname and expose that function in the test environment, the you can stub that instead

rwaldron commented 8 years ago

Released in v0.5.2