diff options
| author | ruki <[email protected]> | 2021-06-29 00:08:26 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2021-06-29 00:08:26 +0800 |
| commit | 61147dc43fd140910c6e1ebfd8efd58d7acce78a (patch) | |
| tree | bb40c3a3ad4d44067f53efe6f34cb2f8f359675c | |
| parent | 7889872bbab1af633391e9fff588e36ea90419af (diff) | |
add trim trailing spaces scripts
| -rw-r--r-- | xmake/modules/private/utils/trim_trailing_spaces.lua | 13 |
1 files changed, 13 insertions, 0 deletions
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 |
