Skip to content

Commit

Permalink
refactor(nx-python): improve regex usage and optional chaining in dep…
Browse files Browse the repository at this point in the history
…endency handling
  • Loading branch information
lucasvieirasilva committed Dec 13, 2024
1 parent 3225f7a commit 09694fd
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/nx-python/src/generators/uv-project/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ function addTestDependencies(
) {
const newDependencies = [...dependencies];
const dependencyNames = dependencies
.map((dep) => dep.match(/^[a-zA-Z0-9-]+/)?.[0])
.map((dep) => /^[a-zA-Z0-9-]+/.exec(dep)?.[0])
.filter((d) => !!d);

if (
Expand Down
2 changes: 1 addition & 1 deletion packages/nx-python/src/provider/poetry/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export async function getPoetryVersion() {
}
const versionRegex = /version (\d+\.\d+\.\d+)/;
const match = result.stdout.toString().trim().match(versionRegex);
const version = match && match[1];
const version = match?.[1];
return version;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/nx-python/src/provider/uv/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ export class UVProvider implements IProvider {
? packageMetadata?.['requires-dist']?.[dep]
: packageMetadata?.['requires-dev']?.[category]?.[dep];

if (!depMetadata || !depMetadata.editable) {
if (!depMetadata?.editable) {
continue;
}

Expand Down

0 comments on commit 09694fd

Please sign in to comment.