Skip to content

Commit 9a2e3c1

Browse files
authored
fix #177 (#178)
* 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
1 parent 4150bf0 commit 9a2e3c1

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

start.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
'use strict';
22
const spawn = require('child_process').spawn;
3-
const path = require("path");
3+
const path = require('path');
4+
const http = require('http');
45
const https = require('https');
56

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

6667
main().catch(err => {
6768
console.error(err);
68-
console.error(err.stack);
69-
process.exit(err.code || -1);
69+
process.exit(-1);
7070
})

0 commit comments

Comments
 (0)