Skip to content

Watch errors #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 10, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .jscsrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"excludeFiles": [
"node_modules/**",
"test-app/dist/**"
"test-app/dist/**",
"test-app/error"
],
"requireCurlyBraces": [
"if",
1 change: 1 addition & 0 deletions .jshintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/node_modules
/test-app/dist
/test-app/error
10 changes: 6 additions & 4 deletions bin/simplifyify.js
Original file line number Diff line number Diff line change
@@ -66,16 +66,18 @@ program
})
.on('error', function(err, fileSet) {
// Log an error
var message = process.env.DEBUG ? err.stack : err.message;
if (fileSet && fileSet.entry) {
console.error('Error bundling %s\n%s', fileSet.entry, message);
if (fileSet && fileSet.entryFile) {
console.error('Error bundling %s\n%s', fileSet.entryFile, err);
}
else {
var message = process.env.DEBUG ? err.stack : err.message;
console.error(message);
}

// Exit the app with an error code
process.exit(1);
if (!program.watch) {
process.exit(1);
}
});
});

1 change: 1 addition & 0 deletions lib/write-bundles.js
Original file line number Diff line number Diff line change
@@ -158,6 +158,7 @@ function addCoverageTransform(b) {
function bundle(b, fileSet) {
var stream = b.bundle();
stream.on('end', b.emit.bind(b, 'end'));
stream.on('error', b.emit.bind(b, 'error'));

if (fileSet.mapFile) {
util.ensureFileExists(fileSet.mapFile);
1 change: 1 addition & 0 deletions test-app/error/error.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log('this is an error'))
22 changes: 22 additions & 0 deletions tests/watch.spec.js
Original file line number Diff line number Diff line change
@@ -216,4 +216,26 @@ describe('simplifyify --watch', function() {
done();
}
});

it('should report errors', function(done) {
this.timeout(10000);

// Run Watchify
var watchify = helper.run('test-app/error/error.js --watch --outfile test-app/dist/error.js', onExit);

// Check the initial outputs after a few seconds
setTimeout(firstCheck, 3000);

function firstCheck() {
watchify.kill();
}

// Verify the final results
function onExit(err, stdout, stderr) {
expect(stderr).to.be.ok;
done();
}

});

});