Skip to content

Commit

Permalink
Merge pull request #6 from HourlyNerd/master
Browse files Browse the repository at this point in the history
chore(exceptions): better error reporting
  • Loading branch information
CaryLandholt committed Apr 10, 2015
2 parents 389967b + f3543bd commit 436d601
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions index.coffee
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
es = require 'event-stream'
ngClassify = require 'ng-classify'
gutil = require 'gulp-util'

module.exports = (opt) ->
modifyFile = (file) ->
return if file.isNull()
@emit 'data', file

return if file.isStream()
@emit 'error', new Error 'gulp-ngClassify: Streaming not supported'
@emit 'error', new gutil.PluginError 'gulp-ng-classify', 'Streaming not supported'

str = file.contents.toString 'utf8'
data = ''
Expand All @@ -17,10 +18,11 @@ module.exports = (opt) ->
options = if isFunction then opt(file) else opt
data = ngClassify str, options
catch err
return @emit 'error', new Error err
err.filename = file.path
return @emit 'error', new gutil.PluginError 'gulp-ng-classify', err

file.contents = new Buffer data

@emit 'data', file

es.through modifyFile
es.through modifyFile

0 comments on commit 436d601

Please sign in to comment.