Skip to content

Commit

Permalink
fix #177 (#178)
Browse files Browse the repository at this point in the history
* Compatible with repository addresses using http protocol.

https protocol is used by default.
For special needs,  can set the URL to http:// or be compatible.

* Fixed exit-code error

in catch, the exit code should be fixed to-1
  • Loading branch information
kerwin612 authored Jul 28, 2023
1 parent 4150bf0 commit 9a2e3c1
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions start.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
'use strict';
const spawn = require('child_process').spawn;
const path = require("path");
const path = require('path');
const http = require('http');
const https = require('https');

const get = (url, options = {}) => new Promise((resolve, reject) => https
const get = (url, options = {}) => new Promise((resolve, reject) => ((new URL(url).protocol === 'http:') ? http : https)
.get(url, options, (res) => {
const chunks = [];
res.on('data', (chunk) => chunks.push(chunk));
Expand Down Expand Up @@ -42,8 +43,8 @@ const trim = (value, charlist) => trimLeft(trimRight(value, charlist));
const main = async () => {
let branch = process.env.INPUT_BRANCH;
const repository = trim(process.env.INPUT_REPOSITORY || process.env.GITHUB_REPOSITORY);
const github_url_protocol = trim(process.env.INPUT_GITHUB_URL).split("//")[0];
const github_url = trim(process.env.INPUT_GITHUB_URL).split("//")[1];
const github_url_protocol = trim(process.env.INPUT_GITHUB_URL).split('//')[0];
const github_url = trim(process.env.INPUT_GITHUB_URL).split('//')[1];
if (!branch) {
const headers = {
'User-Agent': 'github.com/ad-m/github-push-action'
Expand All @@ -65,6 +66,5 @@ const main = async () => {

main().catch(err => {
console.error(err);
console.error(err.stack);
process.exit(err.code || -1);
process.exit(-1);
})

0 comments on commit 9a2e3c1

Please sign in to comment.