mirror of
https://github.com/codecov/codecov-action.git
synced 2026-02-09 20:47:26 +00:00
wrap asyncs better
This commit is contained in:
parent
073e65f9d8
commit
8c56af11bc
2 changed files with 93 additions and 70 deletions
96
dist/index.js
vendored
96
dist/index.js
vendored
|
|
@ -14507,49 +14507,61 @@ var exec = __nccwpck_require__(1514);
|
|||
var superagent = __nccwpck_require__(1524);
|
||||
// import buildExec from './buildExec';
|
||||
// const {failCi} = buildExec();
|
||||
console.log('oh hi');
|
||||
var uploader = (function () { return __awaiter(_this, void 0, void 0, function () {
|
||||
var err_1;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
_a.trys.push([0, 2, , 3]);
|
||||
return [4 /*yield*/, superagent.get('https://uploader.codecov.io/latest/codecov-linux')];
|
||||
case 1: return [2 /*return*/, _a.sent()];
|
||||
case 2:
|
||||
err_1 = _a.sent();
|
||||
core.setFailed("Codecov: Could not properly download uploader binary: " + err_1.message);
|
||||
return [3 /*break*/, 3];
|
||||
case 3: return [2 /*return*/];
|
||||
}
|
||||
try {
|
||||
var uploader = function () {
|
||||
return function () { return __awaiter(_this, void 0, void 0, function () {
|
||||
var uploadBinary, err_1;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
_a.trys.push([0, 2, , 3]);
|
||||
return [4 /*yield*/, superagent.get('https://uploader.codecov.io/latest/codecov-linux')];
|
||||
case 1:
|
||||
uploadBinary = _a.sent();
|
||||
return [2 /*return*/, uploadBinary];
|
||||
case 2:
|
||||
err_1 = _a.sent();
|
||||
core.setFailed('Codecov: Could not properly download uploader binary: ' +
|
||||
("" + err_1.message));
|
||||
return [3 /*break*/, 3];
|
||||
case 3: return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
}); };
|
||||
};
|
||||
console.log(uploader);
|
||||
var filename_1 = __dirname + '/uploader';
|
||||
fs.writeFileSync(filename_1, uploader);
|
||||
console.log('wrote it');
|
||||
fs.chmodSync(filename_1, '700');
|
||||
console.log('Did it');
|
||||
console.log(fs.readdirSync(__dirname));
|
||||
console.log(__dirname);
|
||||
(function () {
|
||||
return function () { return __awaiter(_this, void 0, void 0, function () {
|
||||
var err_2;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
_a.trys.push([0, 2, , 3]);
|
||||
return [4 /*yield*/, exec.exec(filename_1)];
|
||||
case 1:
|
||||
_a.sent();
|
||||
return [3 /*break*/, 3];
|
||||
case 2:
|
||||
err_2 = _a.sent();
|
||||
core.setFailed('Codecov: Could not properly run uploader binary: ' +
|
||||
("" + err_2.message));
|
||||
return [3 /*break*/, 3];
|
||||
case 3: return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
}); };
|
||||
});
|
||||
}); })();
|
||||
console.log(uploader);
|
||||
var filename = __dirname + '/uploader';
|
||||
fs.writeFileSync(filename, uploader);
|
||||
console.log('wrote it');
|
||||
fs.chmodSync(filename, '700');
|
||||
console.log('Did it');
|
||||
console.log(fs.readdirSync(__dirname));
|
||||
console.log(__dirname);
|
||||
(function () { return __awaiter(_this, void 0, void 0, function () {
|
||||
var err_2;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
_a.trys.push([0, 2, , 3]);
|
||||
return [4 /*yield*/, exec.exec(filename)];
|
||||
case 1:
|
||||
_a.sent();
|
||||
return [3 /*break*/, 3];
|
||||
case 2:
|
||||
err_2 = _a.sent();
|
||||
core.setFailed("Codecov: Could not properly execute uploader binary: " + err_2.message);
|
||||
return [3 /*break*/, 3];
|
||||
case 3: return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
}); })();
|
||||
}
|
||||
catch (err) {
|
||||
core.setFailed("Codecov: Encountered an unexpected error: " + err.message);
|
||||
}
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
|
|
|||
67
src/index.ts
67
src/index.ts
|
|
@ -9,34 +9,45 @@ const superagent = require('superagent');
|
|||
|
||||
// const {failCi} = buildExec();
|
||||
|
||||
console.log('oh hi');
|
||||
const uploader = (async () => {
|
||||
try {
|
||||
return await superagent.get('https://uploader.codecov.io/latest/codecov-linux');
|
||||
} catch (err) {
|
||||
core.setFailed(
|
||||
`Codecov: Could not properly download uploader binary: ${err.message}`,
|
||||
);
|
||||
}
|
||||
})();
|
||||
try {
|
||||
const uploader = () => {
|
||||
return async () => {
|
||||
try {
|
||||
const uploadBinary = await superagent.get('https://uploader.codecov.io/latest/codecov-linux');
|
||||
return uploadBinary;
|
||||
} catch (err) {
|
||||
core.setFailed(
|
||||
'Codecov: Could not properly download uploader binary: ' +
|
||||
`${err.message}`,
|
||||
);
|
||||
}
|
||||
};
|
||||
};
|
||||
console.log(uploader);
|
||||
const filename = __dirname + '/uploader';
|
||||
fs.writeFileSync(filename, uploader);
|
||||
console.log('wrote it');
|
||||
|
||||
console.log(uploader);
|
||||
const filename = __dirname + '/uploader';
|
||||
fs.writeFileSync(filename, uploader);
|
||||
console.log('wrote it');
|
||||
fs.chmodSync(filename, '700');
|
||||
|
||||
fs.chmodSync(filename, '700');
|
||||
console.log('Did it');
|
||||
console.log(fs.readdirSync(__dirname));
|
||||
console.log(__dirname);
|
||||
|
||||
console.log('Did it');
|
||||
console.log(fs.readdirSync(__dirname));
|
||||
console.log(__dirname);
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
await exec.exec(filename);
|
||||
} catch (err) {
|
||||
core.setFailed(
|
||||
`Codecov: Could not properly execute uploader binary: ${err.message}`,
|
||||
);
|
||||
}
|
||||
})();
|
||||
() => {
|
||||
return async () => {
|
||||
try {
|
||||
await exec.exec(filename);
|
||||
} catch (err) {
|
||||
core.setFailed(
|
||||
'Codecov: Could not properly run uploader binary: ' +
|
||||
`${err.message}`,
|
||||
);
|
||||
}
|
||||
};
|
||||
};
|
||||
} catch (err) {
|
||||
core.setFailed(
|
||||
`Codecov: Encountered an unexpected error: ${err.message}`,
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue