Fix race condition in get_file

This commit is contained in:
Shivam Mathur
2019-09-06 18:04:53 +05:30
parent 202f1bbec1
commit 2f94ea1a79
9 changed files with 94 additions and 114 deletions
+12 -4
View File
@@ -18,14 +18,22 @@ var __importStar = (this && this.__importStar) || function (mod) {
Object.defineProperty(exports, "__esModule", { value: true });
const core = __importStar(require("@actions/core"));
const exec_1 = require("@actions/exec/lib/exec");
var https = require('https');
const https = require('https');
const fs = require('fs');
function get_file(filename) {
return __awaiter(this, void 0, void 0, function* () {
let github_path = 'https://raw.githubusercontent.com/shivammathur/setup-php/develop/src/';
let github_path = 'https://raw.githubusercontent.com/shivammathur/setup-php/master/src/';
const file = fs.createWriteStream(filename);
const request = https.get(github_path + filename, function (response) {
response.pipe(file);
file.on('open', function (fd) {
https.get(github_path + filename, function (response) {
response
.on('data', function (chunk) {
file.write(chunk);
})
.on('end', function () {
file.end();
});
});
});
});
}