Skip to content

Commit 06a1c9d

Browse files
Apply suggestions from code review
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent 9c9118b commit 06a1c9d

2 files changed

Lines changed: 10 additions & 24 deletions

File tree

‎packages/http-client-python/eng/scripts/setup/install-runner.js‎

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,14 @@ const __dirname = dirname(fileURLToPath(import.meta.url));
1414
const compiledPath = join(__dirname, "../../../dist/scripts/setup/install.js");
1515

1616
try {
17+
await import("./install.ts");
18+
} catch (err) {
19+
if (err?.code !== "ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING") {
20+
throw err;
21+
}
1722
if (existsSync(compiledPath)) {
18-
// Installed from npm package: use pre-compiled JavaScript.
19-
// Use pathToFileURL so Windows absolute paths (D:\...) are valid ESM URLs.
2023
await import(pathToFileURL(compiledPath).href);
2124
} else {
22-
// Development context: TypeScript source works via native type stripping.
23-
await import("./install.ts");
24-
}
25-
} catch (err) {
26-
if (err?.code === "ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING") {
27-
// Running from node_modules without pre-compiled JS — this shouldn't
28-
// happen for a properly built package, but fail gracefully rather than
29-
// blocking the install.
3025
console.log("Python environment setup skipped: run 'npm run build' first."); // eslint-disable-line no-console
31-
} else {
32-
throw err;
3326
}
3427
}

‎packages/http-client-python/eng/scripts/setup/prepare-runner.js‎

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,14 @@ const __dirname = dirname(fileURLToPath(import.meta.url));
1414
const compiledPath = join(__dirname, "../../../dist/scripts/setup/prepare.js");
1515

1616
try {
17+
await import("./prepare.ts");
18+
} catch (err) {
19+
if (err?.code !== "ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING") {
20+
throw err;
21+
}
1722
if (existsSync(compiledPath)) {
18-
// Installed from npm package: use pre-compiled JavaScript.
19-
// Use pathToFileURL so Windows absolute paths (D:\...) are valid ESM URLs.
2023
await import(pathToFileURL(compiledPath).href);
2124
} else {
22-
// Development context: TypeScript source works via native type stripping.
23-
await import("./prepare.ts");
24-
}
25-
} catch (err) {
26-
if (err?.code === "ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING") {
27-
// Running from node_modules without pre-compiled JS — this shouldn't
28-
// happen for a properly built package, but fail gracefully rather than
29-
// blocking the install.
3025
console.log("Python environment prepare skipped: run 'npm run build' first."); // eslint-disable-line no-console
31-
} else {
32-
throw err;
3326
}
3427
}

0 commit comments

Comments
 (0)