Skip to content

Commit 246b692

Browse files
authored
Merge pull request #17 from blink1073/ensure-newline
2 parents 91bbb3e + 870a705 commit 246b692

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

.github/workflows/tests.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
name: Tests
22

3-
on: [push]
3+
on:
4+
push:
5+
branches: ["master"]
6+
pull_request:
7+
# Run once a day.
8+
schedule:
9+
- cron: "0 8 * * *"
410

511
concurrency:
612
group: 'tests-${{ github.head_ref || github.run_id }}'

hatch_nodejs_version/version_source.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,15 @@ 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.
159161
with open(path, "r") as f:
160-
data = json.load(f)
162+
raw_data = f.read()
163+
164+
data = json.loads(raw_data)
161165

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

0 commit comments

Comments
 (0)