From e06607601af4b462e79342099ad685b5a5ce5e68 Mon Sep 17 00:00:00 2001 From: Alexander Dawes Date: Tue, 13 Jun 2017 15:04:46 +0100 Subject: [PATCH] Remove file trimming as this can sometimes change the meaning of the file (eg in the case of yaml files where whitespace and indentation is important) --- lib/consul/index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/consul/index.js b/lib/consul/index.js index b1fbdad..366e44b 100644 --- a/lib/consul/index.js +++ b/lib/consul/index.js @@ -180,7 +180,7 @@ var file_modified = function(branch, file, cb) { fs.readFile(file_path, {encoding: 'utf8'}, function (err, body) { /* istanbul ignore if */ if (err) return cb('Failed to read key ' + file_path + ' due to ' + err); - body = body ? body.trim() : ''; + body = body || ''; try { var obj = JSON.parse(body); populate_kvs_from_object(branch, create_key_name(branch, file), obj, kvs, cb); @@ -227,7 +227,7 @@ var file_modified = function(branch, file, cb) { fs.readFile(file_path, {encoding: 'utf8'}, function (err, body) { /* istanbul ignore if */ if (err) return cb('Failed to read key ' + file_path + ' due to ' + err); - body = body ? body.trim() : ''; + body = body || ''; try { var obj = yaml.safeLoad(body); populate_kvs_from_object(branch, create_key_name(branch, file), obj, kvs, cb); @@ -242,7 +242,7 @@ var file_modified = function(branch, file, cb) { fs.readFile(fqf, {encoding: 'utf8'}, function (err, body) { /* istanbul ignore if */ if (err) return cb('Failed to read key ' + fqf + ' due to ' + err); - body = body ? body.trim() : ''; + body = body || ''; write_content_to_consul(create_key_name(branch, file), body, cb); }); };