From 61147dc43fd140910c6e1ebfd8efd58d7acce78a Mon Sep 17 00:00:00 2001 From: ruki Date: Tue, 29 Jun 2021 00:08:26 +0800 Subject: add trim trailing spaces scripts --- xmake/modules/private/utils/trim_trailing_spaces.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 xmake/modules/private/utils/trim_trailing_spaces.lua diff --git a/xmake/modules/private/utils/trim_trailing_spaces.lua b/xmake/modules/private/utils/trim_trailing_spaces.lua new file mode 100644 index 000000000..b40371c39 --- /dev/null +++ b/xmake/modules/private/utils/trim_trailing_spaces.lua @@ -0,0 +1,13 @@ +function main(pattern) + for _, filepath in ipairs(os.files(pattern)) do + local filedata = io.readfile(filepath) + if filedata then + local filedata2 = {} + for _, line in ipairs(filedata:split('\n', {strict = true})) do + line = line:rtrim() + table.insert(filedata2, line) + end + io.writefile(filepath, table.concat(filedata2, "\n")) + end + end +end -- cgit v1.3.1