electron/script/generate_node_version_header.py
Charles Kerr 61ddb1aa07
chore: bump pylint to 2.17 (#41576)
* build: bump pylint to 2.17

Xref: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5062345

* fix pylint consider-using-f-string warnings pt 1: use flynt for automated fixes

* fix pylint consider-using-f-string warnings pt 2: manual fixes

* fix pylint consider-using-with warnings

* fix pylint line-too-long warnings

* fix pylint unspecified-encoding warnings

* fix py lint consider-using-generator warning

* fixup! fix pylint unspecified-encoding warnings

* fix pylint line-too-long warnings
2024-03-21 09:48:23 -04:00

27 lines
705 B
Python
Executable file

#!/usr/bin/env python3
import re
import sys
node_version_file = sys.argv[1]
out_file = sys.argv[2]
NMV = None
if len(sys.argv) > 3:
NMV = sys.argv[3]
with open(node_version_file, 'r', encoding='utf-8') as in_file, \
open(out_file, 'w', encoding='utf-8') as out_file:
changed = False
contents = in_file.read()
new_contents = re.sub(
r'^#define NODE_MODULE_VERSION [0-9]+$',
'#define NODE_MODULE_VERSION ' + NMV,
contents,
flags=re.MULTILINE)
changed = contents != new_contents
if not changed and NMV is not None:
raise Exception("Did not modify the NMV from nodes value, this value MUST "
"differ from node")
out_file.writelines(new_contents)