Skip to content

Commit

Permalink
Build js
Browse files Browse the repository at this point in the history
  • Loading branch information
svenstaro committed Sep 4, 2019
1 parent 77a52a7 commit 0067325
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions lib/main.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Expand All @@ -23,13 +22,13 @@ function get_release_by_tag(tag, octokit, context) {
return __awaiter(this, void 0, void 0, function* () {
try {
core.debug(`Getting release by tag ${tag}.`);
return yield octokit.repos.getReleaseByTag(Object.assign(Object.assign({}, context.repo), { tag: tag }));
return yield octokit.repos.getReleaseByTag(Object.assign({}, context.repo, { tag: tag }));
}
catch (error) {
// If this returns 404, we need to create the release first.
if (error.status === 404) {
core.debug(`Release for tag ${tag} doesn't exist yet so we'll create it now.`);
return yield octokit.repos.createRelease(Object.assign(Object.assign({}, context.repo), { tag_name: tag }));
return yield octokit.repos.createRelease(Object.assign({}, context.repo, { tag_name: tag }));
}
else {
throw error;
Expand All @@ -42,12 +41,12 @@ function upload_to_release(release, file, asset_name, tag, overwrite, octokit, c
const file_size = fs.statSync(file).size;
const file_bytes = fs.readFileSync(file);
// Check for duplicates.
const assets = yield octokit.repos.listAssetsForRelease(Object.assign(Object.assign({}, context.repo), { release_id: release.data.id }));
const assets = yield octokit.repos.listAssetsForRelease(Object.assign({}, context.repo, { release_id: release.data.id }));
const duplicate_asset = assets.data.find(a => a.name === asset_name);
if (duplicate_asset !== undefined) {
if (overwrite === "true") {
core.debug(`An asset called ${asset_name} already exists in release ${tag} so we'll overwrite it.`);
yield octokit.repos.deleteReleaseAsset(Object.assign(Object.assign({}, context.repo), { asset_id: duplicate_asset.id }));
yield octokit.repos.deleteReleaseAsset(Object.assign({}, context.repo, { asset_id: duplicate_asset.id }));
}
else {
core.setFailed(`An asset called ${asset_name} already exists.`);
Expand Down

0 comments on commit 0067325

Please sign in to comment.