Skip to content
This repository has been archived by the owner on Jun 28, 2024. It is now read-only.

Support toml .version and improve path detection #232

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions sample/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ Inflector = "0.11.4"
block-modes = "0.8.1" # crates: disable-check
jpegxl-sys = "0.8.2"
tracing = "=0.1.37"
smoldot.version = "0.17.0"

[dependencies.depsonpath]
version = "7.0.0-alpha1"
path = "../lib"

[workspace.dependencies]
my_package.path = "../lib"
my_package2 = { path = "../" }

[dependencies.clap]
version = "3.0.0-beta.2"
Expand Down
2 changes: 1 addition & 1 deletion src/core/Item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/
export default class Item {
key: string = "";
values: Array<any> = [];
values: Array<Item> = [];
value: string | undefined = "";
start: number = -1;
end: number = -1;
Expand Down
7 changes: 4 additions & 3 deletions src/toml/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,12 @@ export function findCrateAndVersion(
function findVersion(item: Item): Item[] {
let dependencies: Item[] = [];
for (const field of item.values) {
if (field.key.endsWith(".workspace")) continue;
if (field.key.endsWith(".workspace") || field.key.endsWith(".path")) continue;
if (field.values.length > 0) {
const dependency = findVersionTable(field);
if (dependency) dependencies.push(dependency);
} else if (field.value != null) {
if (field.key.endsWith(".version")) field.key = field.key.replace(".version", "");
dependencies.push(field)
}
}
Expand All @@ -80,7 +81,7 @@ function findVersionTable(table: Item): Item | null {
let item = null
let itemName = null;
for (const field of table.values) {
if (field.key === "workspace") return null;
if (field.key === "workspace" || field.key === "path") return null;
if (field.key === "version") {
item = new Item(field);
item.key = table.key;
Expand Down Expand Up @@ -226,7 +227,7 @@ function isCratesDep(i: Item): boolean {
for (let value of i.values) {
if (value.key === "git" || value.key === "path") {
return false;
} else if (value.key === "package") {
} else if (value.key === "package" && value.value !== undefined) {
i.key = value.value;
}
}
Expand Down