Skip to content

Commit 6d7adb8

Browse files
committed
cstdlib: fix trailing newline
- don't add one if there is one already - don't rewrite the file if it's already there
1 parent 32be707 commit 6d7adb8

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

conda_forge_tick/migrators/cstdlib.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,12 @@ def migrate(self, recipe_dir, attrs, **kwargs):
245245
# that in the conda_build_config, and remove all `__osx` constraints in
246246
# the meta.yaml (see further up).
247247
# this line almost always has a selector, keep the alignment
248-
cbc_lines = _replacer(
248+
new_cbc_lines = _replacer(
249249
cbc_lines, r"^MACOSX_DEPLOYMENT_TARGET:", "c_stdlib_version: "
250250
)
251-
252-
with open(fname, "w") as fp:
253-
fp.write("".join(cbc_lines) + "\n")
251+
if new_cbc_lines != cbc_lines:
252+
with open(fname, "w") as fp:
253+
fp.write("".join(new_cbc_lines))
254+
if new_cbc_lines and not new_cbc_lines[-1].endswith("\n"):
255+
# ensure trailing newline
256+
fp.write("\n")

0 commit comments

Comments
 (0)