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

41
dist/index.js vendored
View File

@ -1291,27 +1291,32 @@ 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* () {
const home = yield getVariable('HOME'); try {
yield exec.exec('bash', [ const home = yield getVariable('HOME');
'-c', yield exec.exec('bash', [
` '-c',
set -e # Any command which returns non-zero exit code will cause this shell script to exit immediately `
set -x # Activate debugging to show execution details: all commands will be printed before execution set -e # Any command which returns non-zero exit code will cause this shell script to exit immediately
set -x # Activate debugging to show execution details: all commands will be printed before execution
sudo apt-get install build-essential checkinstall sudo apt-get install build-essential checkinstall
sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev
cd $HOME cd $HOME
wget https://www.python.org/ftp/python/${version}/Python-${version}.tgz wget https://www.python.org/ftp/python/${version}/Python-${version}.tgz
tar -xvf Python-${version}.tgz tar -xvf Python-${version}.tgz
cd Python-${version} cd Python-${version}
./configure ./configure
make make
sudo checkinstall -y sudo checkinstall -y
` `
]); ]);
return `${home}/Python-${version}`; return `${home}/Python-${version}`;
}
catch (_a) {
return null;
}
}); });
} }
exports.downloadLinuxCpython = downloadLinuxCpython; exports.downloadLinuxCpython = downloadLinuxCpython;

View File

@ -16,28 +16,34 @@ 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(
const home = await getVariable('HOME'); version: string
): Promise<string | null> {
try {
const home = await getVariable('HOME');
await exec.exec('bash', [ await exec.exec('bash', [
'-c', '-c',
` `
set -e # Any command which returns non-zero exit code will cause this shell script to exit immediately set -e # Any command which returns non-zero exit code will cause this shell script to exit immediately
set -x # Activate debugging to show execution details: all commands will be printed before execution set -x # Activate debugging to show execution details: all commands will be printed before execution
sudo apt-get install build-essential checkinstall sudo apt-get install build-essential checkinstall
sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev
cd $HOME cd $HOME
wget https://www.python.org/ftp/python/${version}/Python-${version}.tgz wget https://www.python.org/ftp/python/${version}/Python-${version}.tgz
tar -xvf Python-${version}.tgz tar -xvf Python-${version}.tgz
cd Python-${version} cd Python-${version}
./configure ./configure
make make
sudo checkinstall -y sudo checkinstall -y
` `
]); ]);
return `${home}/Python-${version}`; return `${home}/Python-${version}`;
} catch {
return null;
}
} }