Guest User

Untitled

a guest
Aug 13th, 2013
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.  
  3. pogo = require("pogo")
  4. fs = require("fs")
  5. through = require("through")
  6.  
  7. compile = (file) ->
  8.   compiled = ""
  9.   try
  10.     compiled = pogo.compile(fs.readFileSync(file, "utf8"))
  11.   catch e
  12.     throw new Error("PogoScript compilation failed for '" + file + "'\n" + e.toString())
  13.   compiled
  14.  
  15. isPogo = (file) ->
  16.   /\.pogo$/.test file
  17.  
  18. module.exports = (file) ->
  19.   data = ""
  20.   write = (buf) ->
  21.     data += buf
  22.   end = ->
  23.     src = undefined
  24.     try
  25.       src = compile(file, data)
  26.     catch error
  27.       @emit "error", error
  28.     @queue src
  29.     @queue null
  30.   return through()  unless isPogo(file)
  31.   return through(write, end)
Advertisement
Add Comment
Please, Sign In to add comment