From dc49d2f4c3a9b7ffb18d16deaf4ffac5b1755cda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kaan=20Taha=20K=C3=B6ken?= Date: Thu, 29 Aug 2024 11:29:40 +0300 Subject: [PATCH] fix: remove relative path format --- packages/rust/src/generators/binary/generator.spec.ts | 2 +- packages/rust/src/generators/library/generator.spec.ts | 2 +- packages/rust/src/utils/add-to-workspace.ts | 9 ++++++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/rust/src/generators/binary/generator.spec.ts b/packages/rust/src/generators/binary/generator.spec.ts index 3447aca..0b29960 100644 --- a/packages/rust/src/generators/binary/generator.spec.ts +++ b/packages/rust/src/generators/binary/generator.spec.ts @@ -61,7 +61,7 @@ describe('rust generator', () => { }, "workspace": Object { "members": Array [ - "./test_name", + "test_name", ], "resolver": "2", }, diff --git a/packages/rust/src/generators/library/generator.spec.ts b/packages/rust/src/generators/library/generator.spec.ts index d13f64d..b315b9e 100644 --- a/packages/rust/src/generators/library/generator.spec.ts +++ b/packages/rust/src/generators/library/generator.spec.ts @@ -61,7 +61,7 @@ describe('rust generator', () => { }, "workspace": Object { "members": Array [ - "./test_name", + "test_name", ], "resolver": "2", }, diff --git a/packages/rust/src/utils/add-to-workspace.ts b/packages/rust/src/utils/add-to-workspace.ts index c6287c7..58aa2d8 100644 --- a/packages/rust/src/utils/add-to-workspace.ts +++ b/packages/rust/src/utils/add-to-workspace.ts @@ -18,10 +18,13 @@ export function addToCargoWorkspace(tree: Tree, projectPath: string) { throw new Error('Cargo.toml workspace section does not contain members'); } - if (members.includes(projectPath)) { - logger.info(`${projectPath} already exists in the Cargo.toml members`); + // Remove leading './' if it exists + const cleanProjectPath = projectPath.replace(/^\.\//, ''); + + if (members.includes(cleanProjectPath)) { + logger.info(`${cleanProjectPath} already exists in the Cargo.toml members`); } else { - workspace.members = members.concat([projectPath]); + workspace.members = members.concat([cleanProjectPath]); } const newCargoToml = stringifyCargoToml(cargoToml);