Skip to content

Commit 46b98bf

Browse files
Merge pull request #2 from paulcpederson/watch-errors
Watch errors
2 parents 1fce494 + 2aac141 commit 46b98bf

File tree

6 files changed

+33
-5
lines changed

6 files changed

+33
-5
lines changed

.jscsrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"excludeFiles": [
33
"node_modules/**",
4-
"test-app/dist/**"
4+
"test-app/dist/**",
5+
"test-app/error"
56
],
67
"requireCurlyBraces": [
78
"if",

.jshintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
/node_modules
22
/test-app/dist
3+
/test-app/error

bin/simplifyify.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,18 @@ program
6666
})
6767
.on('error', function(err, fileSet) {
6868
// Log an error
69-
var message = process.env.DEBUG ? err.stack : err.message;
70-
if (fileSet && fileSet.entry) {
71-
console.error('Error bundling %s\n%s', fileSet.entry, message);
69+
if (fileSet && fileSet.entryFile) {
70+
console.error('Error bundling %s\n%s', fileSet.entryFile, err);
7271
}
7372
else {
73+
var message = process.env.DEBUG ? err.stack : err.message;
7474
console.error(message);
7575
}
7676

7777
// Exit the app with an error code
78-
process.exit(1);
78+
if (!program.watch) {
79+
process.exit(1);
80+
}
7981
});
8082
});
8183

lib/write-bundles.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ function addCoverageTransform(b) {
158158
function bundle(b, fileSet) {
159159
var stream = b.bundle();
160160
stream.on('end', b.emit.bind(b, 'end'));
161+
stream.on('error', b.emit.bind(b, 'error'));
161162

162163
if (fileSet.mapFile) {
163164
util.ensureFileExists(fileSet.mapFile);

test-app/error/error.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
console.log('this is an error'))

tests/watch.spec.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,4 +216,26 @@ describe('simplifyify --watch', function() {
216216
done();
217217
}
218218
});
219+
220+
it('should report errors', function(done) {
221+
this.timeout(10000);
222+
223+
// Run Watchify
224+
var watchify = helper.run('test-app/error/error.js --watch --outfile test-app/dist/error.js', onExit);
225+
226+
// Check the initial outputs after a few seconds
227+
setTimeout(firstCheck, 3000);
228+
229+
function firstCheck() {
230+
watchify.kill();
231+
}
232+
233+
// Verify the final results
234+
function onExit(err, stdout, stderr) {
235+
expect(stderr).to.be.ok;
236+
done();
237+
}
238+
239+
});
240+
219241
});

0 commit comments

Comments
 (0)