Skip to content

Commit

Permalink
t2 run: temporary restriction to remote process stdin forwarding (LAN…
Browse files Browse the repository at this point in the history
… only)

Signed-off-by: Rick Waldron <waldron.rick@gmail.com>
  • Loading branch information
rwaldron committed Jun 21, 2016
1 parent 1ba5408 commit 90eac0e
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 4 deletions.
8 changes: 5 additions & 3 deletions lib/tessel/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -383,9 +383,11 @@ exportables.run = function(tessel, opts) {
// When the stream closes, return from the function
remoteProcess.once('close', resolve);

// Pipe input TO the remote process.
process.stdin.pipe(remoteProcess.stdin);
process.stdin.setRawMode(true);
if (tessel.connection.connectionType === 'LAN') {
// Pipe input TO the remote process.
process.stdin.pipe(remoteProcess.stdin);
process.stdin.setRawMode(true);
}

// Pipe output FROM the remote process.
remoteProcess.stdout.pipe(process.stdout);
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
},
"homepage": "https://github.com/tessel/t2-cli",
"devDependencies": {
"coveralls": "^2.11.9",
"grunt": "^0.4.5",
"grunt-cli": "^0.1.13",
"grunt-contrib-jshint": "^0.11.2",
Expand Down
28 changes: 27 additions & 1 deletion test/unit/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -523,9 +523,11 @@ exports['deploy.run'] = {
});
},

runStdInOut: function(test) {
runStdInOutLan: function(test) {
test.expect(4);

this.tessel.connection.connectionType = 'LAN';

this.exec = sandbox.stub(this.tessel.connection, 'exec', (command, options, callback) => {
callback(null, this.tessel._rps);
this.tessel._rps.emit('close');
Expand All @@ -545,6 +547,30 @@ exports['deploy.run'] = {
test.done();
});
},

runStdInOutUsb: function(test) {
test.expect(2);

this.tessel.connection.connectionType = 'USB';

this.exec = sandbox.stub(this.tessel.connection, 'exec', (command, options, callback) => {
callback(null, this.tessel._rps);
this.tessel._rps.emit('close');
});

this.stdinPipe = sandbox.stub(process.stdin, 'pipe');
this.stdinSetRawMode = sandbox.stub(process.stdin, 'setRawMode');

deploy.run(this.tessel, {
resolvedEntryPoint: 'foo',
lang: deployment.js,
}).then(() => {
test.equal(this.stdinPipe.callCount, 0);
test.equal(this.stdinSetRawMode.callCount, 0);
test.done();
});
},

};

exports['deploy.createShellScript'] = {
Expand Down

0 comments on commit 90eac0e

Please sign in to comment.