-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Node version output to
t2 version
command (#679)
Fixes #667
- Loading branch information
Showing
5 changed files
with
219 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// System Objects | ||
// ... | ||
|
||
// Third Party Dependencies | ||
// ... | ||
|
||
// Internal | ||
var Tessel = require('./tessel'); | ||
|
||
/* | ||
Gathers node version. | ||
*/ | ||
Tessel.prototype.fetchCurrentNodeVersion = function() { | ||
return this.simpleExec(['node', '--version']) | ||
.then(version => { | ||
// strip the `v` preceding the version | ||
return version.trim().substring(1); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Test dependencies are required and exposed in common/bootstrap.js | ||
|
||
exports['Tessel.prototype.fetchCurrentNodeVersion'] = { | ||
setUp: function(done) { | ||
this.sandbox = sinon.sandbox.create(); | ||
this.logsWarn = this.sandbox.stub(logs, 'warn', function() {}); | ||
this.logsInfo = this.sandbox.stub(logs, 'info', function() {}); | ||
this.logsBasic = this.sandbox.stub(logs, 'basic', function() {}); | ||
this.tessel = TesselSimulator(); | ||
|
||
this.simpleExec = this.sandbox.stub(Tessel.prototype, 'simpleExec', () => { | ||
return Promise.resolve('v4.2.1'); | ||
}); | ||
|
||
done(); | ||
}, | ||
|
||
tearDown: function(done) { | ||
this.sandbox.restore(); | ||
this.tessel.mockClose(); | ||
|
||
done(); | ||
}, | ||
|
||
properVersionReturned: function(test) { | ||
test.expect(3); | ||
|
||
this.tessel.fetchCurrentNodeVersion() | ||
.then(version => { | ||
test.equal(this.simpleExec.callCount, 1); | ||
test.equal(this.simpleExec.calledWith(['node', '--version']), true); | ||
test.equal(version, '4.2.1'); | ||
test.done(); | ||
}) | ||
.catch(error => { | ||
test.ok(false, `properVersionReturned failed: ${error.toString()}`); | ||
test.done(); | ||
}); | ||
} | ||
}; |