Permalink
Browse files

Merge branch 'master' of git://github.com/chrisfjones/coffin

  • Loading branch information...
2 parents 92ea8f1 + f13203f commit c1e30b73c81e084795bbe1cf0b1f771a94db38d8 @rkive rkive committed Feb 28, 2012
Showing with 38 additions and 23 deletions.
  1. +2 −0 .gitignore
  2. +1 −1 README.md
  3. +4 −2 lib/coffin.js
  4. +18 −10 lib/command.js
  5. +1 −1 package.json
  6. +2 −1 src/coffin.coffee
  7. +10 −8 src/command.coffee
View
@@ -7,3 +7,5 @@ examples/quick.coffin
examples/simple.template
examples/test_module.coffee
+
+tmp*
View
@@ -1 +1 @@
- [![Build Status](https://secure.travis-ci.org/rkive/coffin.png)](http://travis-ci.org/rkive/coffin)
+ [![Build Status](https://secure.travis-ci.org/chrisfjones/coffin.png)](http://travis-ci.org/chrisfjones/coffin)
View
@@ -1,10 +1,12 @@
(function() {
- var CloudFormationTemplateContext, CoffeeScript, fs, path,
+ var CloudFormationTemplateContext, CoffeeScript, fs, path, vm,
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
__slice = Array.prototype.slice;
fs = require('fs');
+ vm = require('vm');
+
path = require('path');
CoffeeScript = require('coffee-script');
@@ -270,7 +272,7 @@
compiled = CoffeeScript.compile(match[3], {
bare: true
});
- chunks.push(eval(compiled));
+ chunks.push(vm.runInThisContext(compiled));
text = match[4];
match = text.match(pattern);
}
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -1,6 +1,6 @@
{
"name": "coffin",
- "version": "0.0.6",
+ "version": "0.1.0",
"description": "Coffee dsl for aws cloudformation",
"keywords": ["coffeescript", "coffee-script", "aws", "cloudformation"],
"author": "Chris Jones",
View
@@ -1,4 +1,5 @@
fs = require 'fs'
+vm = require 'vm'
path = require 'path'
CoffeeScript = require 'coffee-script'
@@ -158,7 +159,7 @@ class CloudFormationTemplateContext
while match
chunks.push match[1]
compiled = CoffeeScript.compile match[3], {bare: true}
- chunks.push eval compiled
+ chunks.push vm.runInThisContext compiled
text = match[4]
match = text.match pattern
chunks.push text if text and text.length > 0
View
@@ -31,13 +31,15 @@ compileTemplate = (source, params, callback) =>
console.error "#{source} not found"
process.exit 1
tabbedLines = []
- tabbedLines.push " @CoffinParams = #{JSON.stringify params}"
+ if !params?
+ params = []
+ tabbedLines.push " @ARGV = #{JSON.stringify params}"
(tabbedLines.push(' ' + line) for line in code.toString().split '\n')
tabbedLines.push ' return'
code = tabbedLines.join '\n'
code = pre + code
compiled = CoffeeScript.compile code, {source, bare: false}
- template = eval compiled
+ template = eval compiled, source
templateString = if commander.pretty then JSON.stringify template, null, 2 else JSON.stringify template
callback? templateString
@@ -152,29 +154,29 @@ printCommand.action (template, params...) ->
validateCommand = commander.command 'validate [template]'
validateCommand.description 'Validate the compiled template. Either an AWS_CLOUDFORMATION_HOME environment variable or a --cfn-home switch is required.'
-validateCommand.action (template) ->
+validateCommand.action (template, params...) ->
validateArgs()
- compileTemplate template, (compiled) ->
+ compileTemplate template, params, (compiled) ->
process.stdout.write "#{coffinChar} #{template} "
tempFileName = generateTempFileName()
writeJsonTemplate compiled, tempFileName, ->
validateTemplate tempFileName, (resultCode) ->
stackCommand = commander.command 'stack [name] [template]'
stackCommand.description 'Create or update the named stack using the compiled template. Either an AWS_CLOUDFORMATION_HOME environment variable or a --cfn-home switch is required.'
-stackCommand.action (name, template) ->
+stackCommand.action (name, template, params...) ->
validateArgs()
- compileTemplate template, (compiled) ->
+ compileTemplate template, params, (compiled) ->
tempFileName = generateTempFileName()
writeJsonTemplate compiled, tempFileName, ->
process.stdout.write "#{coffinChar} #{template} -> "
updateOrCreateStack name, tempFileName, (resultCode) ->
compileCommand = commander.command 'compile [template]'
compileCommand.description 'Compile and write the template. The output file will have the same name as the coffin template plus a shiny new ".template" extension.'
-compileCommand.action (template) ->
+compileCommand.action (template, params...) ->
validateArgs()
- compileTemplate template, (compiled) ->
+ compileTemplate template, params, (compiled) ->
process.stdout.write "#{coffinChar} #{template} -> "
fileName = generateOutputFileName template
writeJsonTemplate compiled, fileName, ->

0 comments on commit c1e30b7

Please sign in to comment.