Skip to content

Commit

Permalink
feat: cli added --context to allow stdin to work with includes
Browse files Browse the repository at this point in the history
  • Loading branch information
nmccready committed Dec 17, 2020
1 parent 1df3952 commit 7f6986f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ var _ = require('lodash'),
bucket: {
desc: 'bucket name required for templates larger than 50k',
},
context: {
desc: 'template full path. only utilized for stdin when the template is piped to this script',
required: false,
string: true,
},
prefix: {
desc: 'prefix for templates uploaded to the bucket',
default: 'cfn-include',
Expand Down Expand Up @@ -79,9 +84,13 @@ if (opts.path) {
console.error('empty template received from stdin');
process.exit(1);
}

const location = opts.context ? path.resolve(opts.context) :
path.join(process.cwd(), 'template.yml');

return include({
template: yaml.load(template),
url: 'file://' + path.join(process.cwd(), 'template.yml'),
url: 'file://' + location,
}).catch(err => console.error(err));
});
}
Expand Down

0 comments on commit 7f6986f

Please sign in to comment.