Fix crash when no version found

This commit is contained in:
SerVB 2020-04-14 19:53:54 +03:00
parent d3f7e79d54
commit 528b040d7e
2 changed files with 54 additions and 43 deletions

5
dist/index.js vendored
View File

@ -1291,6 +1291,7 @@ function getVariable(variableName) {
} }
function downloadLinuxCpython(version) { function downloadLinuxCpython(version) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
try {
const home = yield getVariable('HOME'); const home = yield getVariable('HOME');
yield exec.exec('bash', [ yield exec.exec('bash', [
'-c', '-c',
@ -1312,6 +1313,10 @@ function downloadLinuxCpython(version) {
` `
]); ]);
return `${home}/Python-${version}`; return `${home}/Python-${version}`;
}
catch (_a) {
return null;
}
}); });
} }
exports.downloadLinuxCpython = downloadLinuxCpython; exports.downloadLinuxCpython = downloadLinuxCpython;

View File

@ -16,7 +16,10 @@ async function getVariable(variableName: string): Promise<string> {
return variableValue.trim(); return variableValue.trim();
} }
export async function downloadLinuxCpython(version: string): Promise<string> { export async function downloadLinuxCpython(
version: string
): Promise<string | null> {
try {
const home = await getVariable('HOME'); const home = await getVariable('HOME');
await exec.exec('bash', [ await exec.exec('bash', [
@ -40,4 +43,7 @@ export async function downloadLinuxCpython(version: string): Promise<string> {
]); ]);
return `${home}/Python-${version}`; return `${home}/Python-${version}`;
} catch {
return null;
}
} }