WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 017cba3

Browse files
committed
Refactor utils.js and utils.test.js
- Changed the isPoetryV2 variable name to poetryV2Mode - removed try catch block while assigning poetryV2Mode in pipFrozenTree function - Added few comments Signed-off-by: ambuj <[email protected]>
1 parent e2cd176 commit 017cba3

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

lib/helpers/utils.js

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4902,7 +4902,7 @@ export function parsePyProjectTomlFile(tomlFile) {
49024902
}
49034903
}
49044904

4905-
let isPoetryV2 = false;
4905+
let poetryV2Mode = false;
49064906
let poetryMode = false;
49074907
let uvMode = false;
49084908
let hatchMode = false;
@@ -4925,11 +4925,12 @@ export function parsePyProjectTomlFile(tomlFile) {
49254925
) {
49264926
poetryMode = true;
49274927
}
4928+
49284929
const buildRequires = tomlData?.["build-system"]?.["requires"];
49294930
if (buildRequires && Array.isArray(buildRequires)) {
49304931
for (const req of buildRequires) {
49314932
if (req.startsWith("poetry-core") && req.includes(">=2.0")) {
4932-
isPoetryV2 = true;
4933+
poetryV2Mode = true;
49334934
break;
49344935
}
49354936
}
@@ -5038,7 +5039,7 @@ export function parsePyProjectTomlFile(tomlFile) {
50385039
return {
50395040
parentComponent: pkg,
50405041
poetryMode,
5041-
isPoetryV2,
5042+
poetryV2Mode,
50425043
uvMode,
50435044
hatchMode,
50445045
workspacePaths,
@@ -13539,10 +13540,18 @@ export function getPipFrozenTree(
1353913540
thoughtLog("Performing poetry install");
1354013541
let poetryInstallArgs = ["-m", "poetry", "install", "-n", "--no-root"];
1354113542

13542-
const pyprojectpath = safeExistsSync(join(basePath, "pyproject.toml"));
13543-
const isPoetryV2 = parsePyProjectTomlFile(pyprojectpath).isPoetryV2;
13543+
// Storing pyProjectpath after checking the existence of pyproject.toml file
13544+
const pyprojectpath = safeExistsSync(join(basePath, "pyproject.toml"))
13545+
? join(basePath, "pyproject.toml")
13546+
: null;
13547+
let poetryV2Mode = false;
13548+
// Check if the pyproject.toml is not null
13549+
if (pyprojectpath) {
13550+
poetryV2Mode =
13551+
parsePyProjectTomlFile(pyprojectpath).poetryV2Mode || false;
13552+
}
1354413553
// checking if poetryV2 is true or not
13545-
if (isPoetryV2) {
13554+
if (poetryV2Mode) {
1354613555
// Include all dependency groups and extras (Poetry v2+)
1354713556
poetryInstallArgs.push("--all-groups", "--all-extras");
1354813557
}
@@ -13561,7 +13570,7 @@ export function getPipFrozenTree(
1356113570
);
1356213571
poetryInstallArgs = ["install", "-n", "--no-root"];
1356313572

13564-
if (isPoetryV2) {
13573+
if (poetryV2Mode) {
1356513574
// Also include flags when calling poetry directly
1356613575
poetryInstallArgs.push("--all-groups", "--all-extras");
1356713576
}

lib/helpers/utils.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5006,7 +5006,7 @@ test("parse pyproject.toml with poetryv2 requirement", () => {
50065006
},
50075007
},
50085008
});
5009-
expect(retMap.isPoetryV2).toBeTruthy();
5009+
expect(retMap.poetryV2Mode).toBeTruthy();
50105010
});
50115011

50125012
test("parse pyproject.toml with custom poetry source", () => {

0 commit comments

Comments
 (0)