-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch to cloudformation native YAML support
CloudFormation just added support for YAML, with some nice helper tags. In order to keep parsing the YAML and using our !minify tag, we would have had to implement all of the CF tags, which didn't sound fun, so now the minimized code is injected directly into the YAML string in the build step.
- Loading branch information
Showing
6 changed files
with
160 additions
and
273 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,10 @@ | ||
var yaml = require('js-yaml'); | ||
var UglifyJS = require("uglify-js"); | ||
var fs = require('fs'); | ||
|
||
var MinifyYamlType = new yaml.Type('!minify', { | ||
kind: 'scalar', | ||
construct: function(data) { | ||
return UglifyJS.minify(data, { | ||
mangle: { | ||
'toplevel': true | ||
} | ||
}).code; | ||
} | ||
}); | ||
var sqsToLambdaCode = UglifyJS.minify('./src/sqs-to-lambda.js', { | ||
mangle: { 'toplevel': true } | ||
}).code; | ||
|
||
var SCHEMA = yaml.Schema.create([ MinifyYamlType ]); | ||
|
||
var templateBody = fs.readFileSync('./cloudformation.yml', 'utf-8'); | ||
var template = yaml.load(templateBody, { schema: SCHEMA }); | ||
|
||
fs.writeFileSync('./cloudformation.json', JSON.stringify(template, null, ' '), 'utf-8'); | ||
var templateBody = fs.readFileSync('./src/cloudformation.yml', 'utf-8'); | ||
var builtTemplate = templateBody.replace('{SQSToLambdaCode}', sqsToLambdaCode); | ||
fs.writeFileSync('./sqs-to-lambda.yml', builtTemplate); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,6 @@ | |
"build": "node build.js" | ||
}, | ||
"dependencies": { | ||
"js-yaml": "^3.5.4", | ||
"uglify-js": "^2.6.2" | ||
} | ||
} |
Oops, something went wrong.