From 86daca585a337b4378f57587a60da8decbaf1d03 Mon Sep 17 00:00:00 2001 From: LN Liberda Date: Sat, 10 Jan 2026 21:35:00 +0100 Subject: [PATCH] Allow empty v1 lockfiles --- src/lib.rs | 14 +++++++++++--- tests/v1_empty/yarn.lock | 4 ++++ 2 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 tests/v1_empty/yarn.lock diff --git a/src/lib.rs b/src/lib.rs index e83804f..2a099a5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,9 +1,8 @@ use nom::{ branch::alt, bytes::complete::{is_not, tag, take, take_till, take_until}, - character::{ - complete::{digit1, line_ending, not_line_ending, one_of, space0, space1}, - streaming::multispace0, + character::complete::{ + digit1, line_ending, multispace0, not_line_ending, one_of, space0, space1, }, combinator::{cond, eof, map, map_res, opt, recognize}, error::{context, ParseError}, @@ -1308,4 +1307,13 @@ __metadata: } ) } + + #[test] + fn empty_lockfile() { + let content = std::fs::read_to_string("tests/v1_empty/yarn.lock").unwrap(); + let res = parse_str(&content).unwrap(); + assert_eq!(res.entries, []); + assert_eq!(res.generator, Generator::Yarn); + assert_eq!(res.version, 1); + } } diff --git a/tests/v1_empty/yarn.lock b/tests/v1_empty/yarn.lock new file mode 100644 index 0000000..fb57ccd --- /dev/null +++ b/tests/v1_empty/yarn.lock @@ -0,0 +1,4 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + +