Skip to content

Commit

Permalink
make the metadata injection optional
Browse files Browse the repository at this point in the history
  • Loading branch information
monken committed Jan 15, 2018
1 parent 3c3f524 commit 0d8fb0f
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ var _ = require('lodash'),
flag: true,
abbr: 'm',
},
metadata: {
help: 'add build metadata to output',
default: false,
flag: true,
},
validate: {
help: 'validate compiled template',
default: false,
Expand Down Expand Up @@ -70,19 +75,21 @@ if (opts.path) {
}

promise.then(function (template) {
try {
var stdout = exec('git log -n 1 --pretty=%H', {
stdio: [0, 'pipe', 'ignore']
}).toString().trim();
} catch (e) { }
if(stdout) _.defaultsDeep(template, {
Metadata: {
CfnInclude: {
GitCommit: stdout,
BuildDate: new Date().toISOString()
if(opts.metadata) {
try {
var stdout = exec('git log -n 1 --pretty=%H', {
stdio: [0, 'pipe', 'ignore']
}).toString().trim();
} catch (e) { }
_.defaultsDeep(template, {
Metadata: {
CfnInclude: {
GitCommit: stdout,
BuildDate: new Date().toISOString(),
}
}
}
});
});
}
if (opts.validate) {
var cfn = new (require('aws-sdk-proxy').CloudFormation)({
region: 'us-east-1'
Expand Down

0 comments on commit 0d8fb0f

Please sign in to comment.