Skip to content

Commit 45a40e9

Browse files
committed
fix: throw an error if could not find the python binary
1 parent 7f2f3d2 commit 45a40e9

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/python/python.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,10 @@ async function findOrSetupPython(version: string, setupDir: string, arch: string
8989
const { setupActionsPython } = await import("./actions_python")
9090
await setupActionsPython(version, setupDir, arch)
9191

92-
foundPython = (await findPython(setupDir))!
92+
foundPython = await findPython(setupDir)
93+
if (foundPython === undefined) {
94+
throw new Error("Python binary could not be found")
95+
}
9396
const binDir = dirname(foundPython)
9497
installInfo = { bin: foundPython, installDir: binDir, binDir }
9598
} catch (err) {
@@ -103,7 +106,10 @@ async function findOrSetupPython(version: string, setupDir: string, arch: string
103106
}
104107

105108
if (foundPython === undefined || installInfo.bin === undefined) {
106-
foundPython = (await findPython(setupDir))!
109+
foundPython = await findPython(setupDir)
110+
if (foundPython === undefined) {
111+
throw new Error("Python binary could not be found")
112+
}
107113
installInfo.bin = foundPython
108114
}
109115

@@ -120,7 +126,10 @@ async function setupPythonSystem(setupDir: string, version: string) {
120126
await setupChocoPack("python3", version)
121127
}
122128
// Adding the bin dir to the path
123-
const bin = (await findPython(setupDir))!
129+
const bin = await findPython(setupDir)
130+
if (bin === undefined) {
131+
throw new Error("Python binary could not be found")
132+
}
124133
const binDir = dirname(bin)
125134
/** The directory which the tool is installed to */
126135
await addPath(binDir)

0 commit comments

Comments
 (0)