Skip to content

Commit 2677401

Browse files
committed
update CONTRIBUTING.md
Signed-off-by: Luke-zhang-04 <[email protected]>
1 parent aa62542 commit 2677401

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

Diff for: CONTRIBUTING.md

+7-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ information to effectively respond to your bug report or contribution.
1111
* [Finding contributions to work on](#finding-contributions-to-work-on)
1212
* [Adding support for a new language](#adding-support-for-a-new-language)
1313
* [Ascii logo](#ascii-logo)
14-
* [Adding support for a new package manager](#adding-support-for-a-new-package-manager)
14+
* [Adding support for a new package manager](#adding-support-for-a-new-package-manager)
1515
* [Project-specific notes](#project-specific-notes)
1616

1717
## Reporting Bugs / Feature Requests
@@ -127,12 +127,16 @@ fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
127127
}
128128
```
129129

130-
3. in `src/onefetch/deps/package_parser.rs`, add a function whose name corresponds to your manager. This function should take in a `string` as the contents of the package manager file, and return `usize` as the number of dependencies
130+
3. in `src/onefetch/deps/package_parser.rs`, add a function whose name corresponds to your manager. This function should take in a `string` as the contents of the package manager file, and return `usize` as the number of dependencies. You should also make sure you catch any edge cases, such as the absence of a `dependencies` field.
131131
```rust
132132
pub fn cargo(contents: &str) -> Result<usize> {
133133
let parsed = contents.parse::<Value>()?;
134+
let count = parsed.get("dependencies");
134135

135-
Ok(parsed["dependencies"].as_table().unwrap().len())
136+
match count {
137+
Some(val) => Ok(val.as_table().unwrap().len()),
138+
None => Ok(0),
139+
}
136140
}
137141
```
138142

0 commit comments

Comments
 (0)