Skip to content

Commit b036c2d

Browse files
authored
Allow empty v1 lockfiles (#31)
1 parent d09eaeb commit b036c2d

2 files changed

Lines changed: 15 additions & 3 deletions

File tree

src/lib.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
use nom::{
22
branch::alt,
33
bytes::complete::{is_not, tag, take, take_till, take_until},
4-
character::{
5-
complete::{digit1, line_ending, not_line_ending, one_of, space0, space1},
6-
streaming::multispace0,
4+
character::complete::{
5+
digit1, line_ending, multispace0, not_line_ending, one_of, space0, space1,
76
},
87
combinator::{cond, eof, map, map_res, opt, recognize},
98
error::{context, ParseError},
@@ -1308,4 +1307,13 @@ __metadata:
13081307
}
13091308
)
13101309
}
1310+
1311+
#[test]
1312+
fn empty_lockfile() {
1313+
let content = std::fs::read_to_string("tests/v1_empty/yarn.lock").unwrap();
1314+
let res = parse_str(&content).unwrap();
1315+
assert_eq!(res.entries, []);
1316+
assert_eq!(res.generator, Generator::Yarn);
1317+
assert_eq!(res.version, 1);
1318+
}
13111319
}

tests/v1_empty/yarn.lock

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2+
# yarn lockfile v1
3+
4+

0 commit comments

Comments
 (0)