mirror of
https://github.com/SPLURT-Station/S.P.L.U.R.T-Station-13.git
synced 2025-12-10 09:54:52 +00:00
CI to check for wrong line ending
This commit is contained in:
@@ -26,6 +26,7 @@ matrix:
|
|||||||
- find . -name "*.json" -not -path "./tgui/node_modules/*" -print0 | xargs -0 python3 ./tools/json_verifier.py
|
- find . -name "*.json" -not -path "./tgui/node_modules/*" -print0 | xargs -0 python3 ./tools/json_verifier.py
|
||||||
- tools/travis/build_tgui.sh
|
- tools/travis/build_tgui.sh
|
||||||
- tools/travis/check_grep.sh
|
- tools/travis/check_grep.sh
|
||||||
|
- python3 tools/travis/check_line_endings.py
|
||||||
- ~/dreamchecker
|
- ~/dreamchecker
|
||||||
|
|
||||||
- name: "Compile All Maps"
|
- name: "Compile All Maps"
|
||||||
|
|||||||
47
tools/travis/check_line_endings.py
Normal file
47
tools/travis/check_line_endings.py
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import glob
|
||||||
|
|
||||||
|
WINDOWS_NEWLINE = b'\r\n'
|
||||||
|
|
||||||
|
FILES_TO_READ = []
|
||||||
|
FILES_TO_READ.extend(glob.glob(r"**\*.dm", recursive=True))
|
||||||
|
FILES_TO_READ.extend(glob.glob(r"**\*.dmm", recursive=True))
|
||||||
|
FILES_TO_READ.extend(glob.glob(r"*.dme"))
|
||||||
|
#for i in FILES_TO_READ:
|
||||||
|
# if os.path.isdir(i):
|
||||||
|
# FILES_TO_READ.remove(i)
|
||||||
|
|
||||||
|
def _reader(filepath):
|
||||||
|
data = open(filepath, "rb")
|
||||||
|
return data
|
||||||
|
|
||||||
|
def main():
|
||||||
|
filelist = []
|
||||||
|
foundfiles = False
|
||||||
|
|
||||||
|
for file in FILES_TO_READ:
|
||||||
|
data = _reader(file)
|
||||||
|
lines = data.readlines()
|
||||||
|
for line in lines:
|
||||||
|
if line.endswith(WINDOWS_NEWLINE):
|
||||||
|
filelist.append(file)
|
||||||
|
foundfiles = True
|
||||||
|
break
|
||||||
|
data.close()
|
||||||
|
|
||||||
|
if not foundfiles:
|
||||||
|
print("No CRLF files found.")
|
||||||
|
sys.exit(0)
|
||||||
|
else:
|
||||||
|
print("Found files with suspected CRLF type.")
|
||||||
|
for i in filelist:
|
||||||
|
print(i)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
Reference in New Issue
Block a user