Skip to content

Commit

Permalink
fix trailing newline handling (#7)
Browse files Browse the repository at this point in the history
* don't always add a newline when writing to stdout

this is making stdout have different output behavior than writing to
files

* also don't auto-chomp templates
  • Loading branch information
doy-stripe authored and ryan-lane committed Jun 5, 2017
1 parent 5a57f0e commit 03ca865
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions confidant_client/formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,10 @@ def get_source(self, environment, template):
return source, template, lambda: False

combined_credentials = combined_credential_pair_format(data)
env = jinja2.Environment(loader=GlobalFileLoader())
env = jinja2.Environment(
loader=GlobalFileLoader(),
keep_trailing_newline=True
)
template = env.get_template(template_file)
return template.render(secrets=combined_credentials['credentials'])

Expand Down Expand Up @@ -211,7 +214,7 @@ def main():
logging.error('Unsupported --out-format.')
sys.exit(1)
if args.out == '-':
print ret
sys.stdout.write(ret)
else:
with open(os.path.join(args.out), 'w') as f:
f.write(ret)
Expand Down

0 comments on commit 03ca865

Please sign in to comment.