This commit is contained in:
Shivam Mathur
2019-09-06 05:17:43 +05:30
commit 8f9786b73f
7058 changed files with 1813932 additions and 0 deletions

44
src/install.ts Normal file
View File

@@ -0,0 +1,44 @@
import * as core from '@actions/core';
import {exec} from '@actions/exec/lib/exec';
const https = require('https');
const fs = require('fs');
async function get_file(filename: string) {
let github_path: string =
'https://raw.githubusercontent.com/shivammathur/setup-php/develop/src/';
const file: any = fs.createWriteStream(filename);
https.get(github_path + filename, function(response: any) {
response.pipe(file);
});
}
async function run() {
try {
let version = process.env['php-version'];
if (!version) {
version = core.getInput('php-version', {required: true});
}
console.log('Input: ' + version);
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);
} else if (os_version == 'win32') {
await get_file('windows.ps1');
await exec('DIR');
await exec('powershell .\\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);
}
} catch (err) {
core.setFailed(err.message);
}
}
run().then(() => {
console.log('done');
});