Add version to the script names while running

This commit is contained in:
Shivam Mathur 2019-09-06 20:46:37 +05:30
parent 8ba904fa24
commit 76bcc07458
2 changed files with 22 additions and 22 deletions

View File

@ -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) {

View File

@ -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);