diff --git a/lib/install.js b/lib/install.js index 4cae30ea..7a9525fa 100644 --- a/lib/install.js +++ b/lib/install.js @@ -20,10 +20,10 @@ const core = __importStar(require("@actions/core")); const exec_1 = require("@actions/exec/lib/exec"); const https = require('https'); const fs = require('fs'); -function get_file(filename) { +function get_file(filename, version) { return __awaiter(this, void 0, void 0, function* () { let github_path = 'https://raw.githubusercontent.com/shivammathur/setup-php/master/src/'; - const file = fs.createWriteStream(filename); + const file = fs.createWriteStream(version + filename); file.on('open', function (fd) { https.get(github_path + filename, function (response) { response @@ -47,19 +47,18 @@ function run() { console.log('Input: ' + version); let os_version = process.platform; if (os_version == 'darwin') { - yield get_file('darwin.sh'); - yield exec_1.exec('sudo chmod a+x darwin.sh'); - yield exec_1.exec('./darwin.sh ' + version); + yield get_file('darwin.sh', version); + yield exec_1.exec('sudo chmod a+x ' + version + 'darwin.sh'); + yield exec_1.exec('./' + version + 'darwin.sh ' + version); } else if (os_version == 'win32') { - yield get_file('windows.ps1'); - yield exec_1.exec('DIR'); - yield exec_1.exec('powershell .\\windows.ps1 -version ' + version); + yield get_file('windows.ps1', version); + yield exec_1.exec('powershell .\\' + version + 'windows.ps1 -version ' + version); } else if (os_version == 'linux') { - yield get_file('linux.sh'); - yield exec_1.exec('sudo chmod a+x linux.sh'); - yield exec_1.exec('./linux.sh ' + version); + yield get_file('linux.sh', version); + yield exec_1.exec('sudo chmod a+x ' + version + 'linux.sh'); + yield exec_1.exec('./' + version + 'linux.sh ' + version); } } catch (err) { diff --git a/src/install.ts b/src/install.ts index da95a41c..2a5ceb7c 100644 --- a/src/install.ts +++ b/src/install.ts @@ -3,10 +3,10 @@ import {exec} from '@actions/exec/lib/exec'; const https = require('https'); const fs = require('fs'); -async function get_file(filename: string) { +async function get_file(filename: string, version: string) { let github_path: string = 'https://raw.githubusercontent.com/shivammathur/setup-php/master/src/'; - const file: any = fs.createWriteStream(filename); + const file: any = fs.createWriteStream(version + filename); file.on('open', function(fd: any) { https.get(github_path + filename, function(response: any) { response @@ -30,17 +30,18 @@ async function run() { let os_version = process.platform; if (os_version == 'darwin') { - await get_file('darwin.sh'); - await exec('sudo chmod a+x darwin.sh'); - await exec('./darwin.sh ' + version); + await get_file('darwin.sh', version); + await exec('sudo chmod a+x ' + version + 'darwin.sh'); + await exec('./' + version + 'darwin.sh ' + version); } else if (os_version == 'win32') { - await get_file('windows.ps1'); - await exec('DIR'); - await exec('powershell .\\windows.ps1 -version ' + version); + await get_file('windows.ps1', version); + await exec( + 'powershell .\\' + version + 'windows.ps1 -version ' + version + ); } else if (os_version == 'linux') { - await get_file('linux.sh'); - await exec('sudo chmod a+x linux.sh'); - await exec('./linux.sh ' + version); + await get_file('linux.sh', version); + await exec('sudo chmod a+x ' + version + 'linux.sh'); + await exec('./' + version + 'linux.sh ' + version); } } catch (err) { core.setFailed(err.message);