Permalink
Browse files

write out messages to stderr if there are no listeners for syntaxError

  • Loading branch information...
1 parent 8a20be2 commit 7f54f3ed8e49d8b84944714da395a036ee9edb64 @substack substack committed Oct 27, 2011
Showing with 25 additions and 4 deletions.
  1. +14 −0 README.markdown
  2. +3 −0 index.js
  3. +7 −3 lib/wrap.js
  4. +1 −1 package.json
View
@@ -147,6 +147,20 @@ This option defaults to false. If `opts.watch` is set to true, default watch
arguments are assumed or you can pass in an object to pass along as the second
parameter to `fs.watchFile()`.
+### bundle events
+
+`b` bundles will also emit events.
+
+#### 'syntaxError', err
+
+This event gets emitted when there is a syntax error somewhere in the build
+process. If you don't listen for this event, the error will be printed to
+stderr.
+
+#### 'bundle'
+
+In watch mode, this event is emitted when a new bundle has been generated.
+
b.bundle()
----------
View
@@ -165,6 +165,9 @@ var exports = module.exports = function (entryFile, opts) {
self.on('syntaxError', function (err) {
ok = false;
+ if (self.listeners('syntaxError').length <= 1) {
+ console.error(err && err.stack || err);
+ }
});
var lastOk = null;
View
@@ -113,7 +113,9 @@ Wrap.prototype.addEntry = function (file, opts) {
var required = detective.find(body);
}
catch (err) {
- self.emit('syntaxError', err);
+ process.nextTick(function () {
+ self.emit('syntaxError', err);
+ });
return self;
}
@@ -230,7 +232,7 @@ Wrap.prototype.reload = function (name) {
try {
this.addEntry(name);
}
- catch(e) {
+ catch (e) {
// Return item back to list
this.appends.splice(this.entries[name], 0, items[0]);
@@ -386,7 +388,9 @@ Wrap.prototype.require = function (mfile, opts) {
var required = detective.find(body);
}
catch (err) {
- self.emit('syntaxError', err);
+ process.nextTick(function () {
+ self.emit('syntaxError', err);
+ });
return self;
}
View
@@ -1,6 +1,6 @@
{
"name" : "browserify",
- "version" : "1.7.4",
+ "version" : "1.7.5",
"description" : "Browser-side require() for js directories and npm modules",
"main" : "index.js",
"bin" : {

0 comments on commit 7f54f3e

Please sign in to comment.