Skip to content

Commit

Permalink
Board: Allow IO plugin to control initialization of repl.
Browse files Browse the repository at this point in the history
If an IO plugin wants to control the repl, it may do so by explicitly setting its own `this.repl = false;`

Signed-off-by: Rick Waldron <[email protected]>
  • Loading branch information
rwaldron committed Apr 18, 2016
1 parent 9ad32f4 commit c7ca9c4
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
9 changes: 9 additions & 0 deletions lib/board.js
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,15 @@ function finalizeAndBroadcast(err, type, io) {
this.pins = Board.Pins(this);
this.MODES = this.io.MODES;

if (typeof io.debug !== "undefined" &&
io.debug === false) {
this.debug = false;
}

if (typeof io.repl !== "undefined" &&
io.repl === false) {
this.repl = false;
}
// In multi-board mode, block the REPL from
// activation. This will be started directly
// by the Board.Collection constructor.
Expand Down
34 changes: 33 additions & 1 deletion test/board.js
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,7 @@ exports["Board.mount"] = {
},
};

exports["Events Forwarded By IO Layer"] = {
exports["Events Forwarded By IO Plugin layer"] = {
setUp: function(done) {
done();
},
Expand Down Expand Up @@ -979,6 +979,38 @@ exports["Events Forwarded By IO Layer"] = {
},
};

exports["Repl controlled by IO Plugin layer"] = {
setUp: function(done) {
done();
},
tearDown: function(done) {
Board.purge();
done();
},
ioForcesReplFalse: function(test) {
test.expect(1);

var io = new MockFirmata();
var board = new Board({
io: io,
debug: false,
});

board.on("ready", function() {
test.equal(this.repl, false);
test.done();
});

// At any point during its own initialization,
// but always _before_ emitting "ready",
// the IO plugin could set this false.
io.repl = false;

io.emit("connect");
io.emit("ready");
},
};

exports["fn"] = {
cache: function(test) {
test.expect(6);
Expand Down

0 comments on commit c7ca9c4

Please sign in to comment.