Skip to content

Commit ca77baa

Browse files
committed
add a trailing newline
1 parent 91bbb3e commit ca77baa

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

hatch_nodejs_version/version_source.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,16 @@ def set_version(self, version: str, version_data):
156156
if not os.path.isfile(path):
157157
raise OSError(f"file does not exist: {self.path}")
158158

159+
# Read the original file so we can see if it has a trailing
160+
# newline character.
161+
with open(path, "r") as f:
162+
raw_data = f.read()
163+
159164
with open(path, "r") as f:
160165
data = json.load(f)
161166

162167
data["version"] = self.python_version_to_node(version)
163168
with open(path, "w") as f:
164169
json.dump(data, f, indent=4)
170+
if raw_data.endswith('\n'):
171+
f.write('\n')

0 commit comments

Comments
 (0)