mirror of
https://github.com/tweag/gomod2nix.git
synced 2024-11-09 12:09:08 +00:00
Merge pull request #25 from yihuang/fix-regex
add regex to filter comment lines
This commit is contained in:
commit
fc5adcc530
1 changed files with 4 additions and 6 deletions
|
@ -10,17 +10,15 @@ let
|
||||||
stripLines = initialLines: foldl' (acc: f: f acc) initialLines [
|
stripLines = initialLines: foldl' (acc: f: f acc) initialLines [
|
||||||
# Strip comments
|
# Strip comments
|
||||||
(lines: map
|
(lines: map
|
||||||
(l:
|
(l: stripStr (elemAt (splitString "//" l) 0))
|
||||||
let
|
|
||||||
m = match "(.*)( )?//.*" l;
|
|
||||||
hasComment = m != null;
|
|
||||||
in
|
|
||||||
stripStr (if hasComment then elemAt m 0 else l))
|
|
||||||
lines)
|
lines)
|
||||||
|
|
||||||
# Strip leading tabs characters
|
# Strip leading tabs characters
|
||||||
(lines: map (l: elemAt (match "(\t)?(.*)" l) 1) lines)
|
(lines: map (l: elemAt (match "(\t)?(.*)" l) 1) lines)
|
||||||
|
|
||||||
|
# Strip comment lines
|
||||||
|
(filter (l: match "[ \t]*//.*" l != null))
|
||||||
|
|
||||||
# Filter empty lines
|
# Filter empty lines
|
||||||
(filter (l: l != ""))
|
(filter (l: l != ""))
|
||||||
];
|
];
|
||||||
|
|
Loading…
Reference in a new issue