Skip to content

Commit

Permalink
Do not local path.join(...) for remote system paths. Fixes gh-632
Browse files Browse the repository at this point in the history
Signed-off-by: Rick Waldron <waldron.rick@gmail.com>
  • Loading branch information
rwaldron committed Apr 2, 2016
1 parent eef32b0 commit 50732a7
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/tessel/update.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// System Objects
var path = require('path');
// ...

// Third Party Dependencies
// ...
Expand All @@ -10,7 +10,7 @@ var logs = require('../logs');
var Tessel = require('./tessel');
var updates = require('../update-fetch');

var updatePath = path.join('/tmp/', updates.OPENWRT_BINARY_FILE);
var updatePath = `/tmp/${updates.OPENWRT_BINARY_FILE}`;
var remoteVersioningFile = '/etc/tessel-version';

/*
Expand Down
31 changes: 30 additions & 1 deletion test/unit/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -781,8 +781,37 @@ exports['Tessel.update'] = {
this.sandbox.restore();
done();
},

updatePathMustNotByPathNormalized: function(test) {
test.expect(4);

var updatePath = `/tmp/${updates.OPENWRT_BINARY_FILE}`;

this.exec = this.sandbox.stub(this.tessel.connection, 'exec', (command, handler) => {
handler(null, this.tessel._rps);
setImmediate(() => {
this.tessel._rps.stdout.emit('data', new Buffer('Upgrade completed'));
this.tessel._rps.emit('close');
});
});

this.openStdinToFile = this.sandbox.stub(commands, 'openStdinToFile');
this.sysupgrade = this.sandbox.stub(commands, 'sysupgrade');

this.tessel.updateOpenWRT(this.newImage.openwrt).then(() => {
test.equal(this.openStdinToFile.callCount, 1);
test.equal(this.sysupgrade.callCount, 1);
test.equal(this.openStdinToFile.lastCall.args[0], updatePath);
test.equal(this.sysupgrade.lastCall.args[0], updatePath);
test.done();
}).catch((error) => {
test.ok(false, error);
test.done();
});
},

standardUpdate: function(test) {
var updatePath = path.join('/tmp/', updates.OPENWRT_BINARY_FILE);
var updatePath = `/tmp/${updates.OPENWRT_BINARY_FILE}`;
// The exec commands that should be run to update OpenWRT
var expectedCommands = [commands.openStdinToFile(updatePath), commands.sysupgrade(updatePath)];
// Which command is being written
Expand Down

0 comments on commit 50732a7

Please sign in to comment.