Skip to content

Commit

Permalink
Merge 6115584 into e07e0d8
Browse files Browse the repository at this point in the history
  • Loading branch information
dead-horse committed Jul 18, 2016
2 parents e07e0d8 + 6115584 commit 8c8c3b0
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
5 changes: 2 additions & 3 deletions .travis.yml
@@ -1,8 +1,7 @@
sudo: false
language: node_js
node_js:
- '6'
- '4'
- '3'
- '2'
- '1'
script: "make test-travis"
after_script: "npm install coveralls@2 && cat ./coverage/lcov.info | coveralls"
8 changes: 7 additions & 1 deletion index.js
Expand Up @@ -72,7 +72,13 @@ proto._load = function (target, field, options) {
}

var names = properties.join('.');
var mod = interopRequire(item.fullpath);
var mod;
try {
mod = interopRequire(item.fullpath);
} catch (err) {
err.message = '[loading] load file: ' + item.fullpath + ', error: ' + err.message;
throw err;
}
// if exist initializer function, run it;
if (initializer) {
mod = initializer(mod);
Expand Down
3 changes: 3 additions & 0 deletions test/fixtures/syntax_error/error.js
@@ -0,0 +1,3 @@
modulde.exports = function (a) {
yield a;
}
10 changes: 9 additions & 1 deletion test/loading.test.js
Expand Up @@ -102,7 +102,7 @@ describe('loading.test.js', function () {
.into(app, 'proxyClasses');
(function() {
app.proxyClasses.UserProxy();
}).should.throw('Class constructors cannot be invoked without \'new\'');
}).should.throw(/cannot be invoked without 'new'/);
var instance = new app.proxyClasses.UserProxy();
instance.getUser().should.eql({ name: 'xiaochen.gaoxc' });
});
Expand Down Expand Up @@ -166,6 +166,14 @@ describe('loading.test.js', function () {
app.model.mod.should.eql({ a: 1 });
});

it('should contain syntax error filepath', function() {
var app = {};
var fixtures = path.join(__dirname, './fixtures/syntax_error');
(function () {
loading(fixtures).into(app, 'model');
}).should.throw(/\[loading\] load file: .*?test\/fixtures\/syntax_error\/error\.js, error:/);
});

// feature detection
function supportEs6Class() {
'use strict';
Expand Down

0 comments on commit 8c8c3b0

Please sign in to comment.