Skip to content

Commit

Permalink
Merge pull request #444 from rwaldron/441
Browse files Browse the repository at this point in the history
Ensure that bundling errors make are surfaced. Fixes gh-441
  • Loading branch information
rwaldron committed Nov 17, 2015
2 parents bbc0559 + aab8155 commit 0726002
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 3 deletions.
2 changes: 2 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ module.exports = function(grunt) {
'lib/**/*.js',
'test/**/*.js',
'Gruntfile.js',
'!test/unit/fixtures/syntax-error/**/*.js',

// This is commented out because there are
// too many errors to address. I went through
Expand All @@ -36,6 +37,7 @@ module.exports = function(grunt) {
'lib/**/*.js',
'test/**/*.js',
'Gruntfile.js',
'!test/unit/fixtures/syntax-error/**/*.js',
// 'resources/**/*.js',
],
options: {
Expand Down
7 changes: 6 additions & 1 deletion bin/tessel-2.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@ function makeCommand(commandName) {

function callControllerWith(methodName, opts) {
return controller[methodName](opts)
.then(module.exports.closeSuccessfulCommand, module.exports.closeFailedCommand);
.then(module.exports.closeSuccessfulCommand, function(opts, err) {
if (typeof opts === 'object' && opts !== null) {
err = opts.message || '';
}
module.exports.closeFailedCommand(opts, err);
});
}

function callControllerCallback(methodName) {
Expand Down
7 changes: 5 additions & 2 deletions lib/tessel/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ actions.sendBundle = function(tessel, filepath, opts) {

// Write the code bundle to the hardware
remoteProcess.stdin.end(bundle);
});
}).catch(reject);
}).catch(reject);
});
});
Expand Down Expand Up @@ -436,7 +436,10 @@ actions.tarBundle = function(opts) {
})
.bundle(function(error, results) {
if (error) {
return reject(error);
return reject({
type: 'err',
message: error.toString()
});
} else {

// If there is only one file in this project, then there is
Expand Down
22 changes: 22 additions & 0 deletions test/unit/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,28 @@ exports['deploy.tarBundle'] = {
}.bind(this));
},

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

var entryPoint = 'index.js';
var slimPath = '__tessel_program__.js';
var target = 'test/unit/fixtures/syntax-error';

deploy.tarBundle({
target: path.normalize(target),
resolvedEntryPoint: entryPoint,
slimPath: slimPath,
slim: true,
}).then(function() {
test.fail();
test.done();
}).catch(function(error) {
test.equal(error.type, 'err');
test.ok(error.message.indexOf('Unexpected token') !== -1);
test.done();
}.bind(this));
},

slimTesselInit: function(test) {
test.expect(8);

Expand Down
9 changes: 9 additions & 0 deletions test/unit/fixtures/syntax-error/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
var tessel = require('tessel');
var other = require('./other');

tessel.led[2].on();

setInterval(function() {
tessel.led[2].toggle();
tessel.led[3].toggle();
}, 100);
1 change: 1 addition & 0 deletions test/unit/fixtures/syntax-error/other.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
this is bogus.
6 changes: 6 additions & 0 deletions test/unit/fixtures/syntax-error/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "syntax-error",
"version": "0.0.1",
"description": "syntax-error",
"main": "./index.js"
}

0 comments on commit 0726002

Please sign in to comment.