coffee.js 632 B

123456789101112131415161718192021
  1. var cs = require("coffee-script")
  2. var TerraformError = require("../../error").TerraformError
  3. exports.compile = function(filePath, fileContents, callback){
  4. try{
  5. var errors = null
  6. var script = cs.compile(fileContents.toString(), { bare: true })
  7. }catch(e){
  8. var errors = e
  9. errors.source = "CoffeeScript"
  10. errors.dest = "JavaScript"
  11. errors.filename = filePath
  12. errors.stack = fileContents.toString()
  13. errors.lineno = parseInt(errors.location.first_line ? errors.location.first_line + 1 : -1)
  14. var script = null
  15. var error = new TerraformError(errors)
  16. }finally{
  17. callback(error, script)
  18. }
  19. }