* 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
This commit is contained in:
12
start.js
12
start.js
@ -1,9 +1,10 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const spawn = require('child_process').spawn;
|
const spawn = require('child_process').spawn;
|
||||||
const path = require("path");
|
const path = require('path');
|
||||||
|
const http = require('http');
|
||||||
const https = require('https');
|
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) => {
|
.get(url, options, (res) => {
|
||||||
const chunks = [];
|
const chunks = [];
|
||||||
res.on('data', (chunk) => chunks.push(chunk));
|
res.on('data', (chunk) => chunks.push(chunk));
|
||||||
@ -42,8 +43,8 @@ const trim = (value, charlist) => trimLeft(trimRight(value, charlist));
|
|||||||
const main = async () => {
|
const main = async () => {
|
||||||
let branch = process.env.INPUT_BRANCH;
|
let branch = process.env.INPUT_BRANCH;
|
||||||
const repository = trim(process.env.INPUT_REPOSITORY || process.env.GITHUB_REPOSITORY);
|
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_protocol = trim(process.env.INPUT_GITHUB_URL).split('//')[0];
|
||||||
const github_url = trim(process.env.INPUT_GITHUB_URL).split("//")[1];
|
const github_url = trim(process.env.INPUT_GITHUB_URL).split('//')[1];
|
||||||
if (!branch) {
|
if (!branch) {
|
||||||
const headers = {
|
const headers = {
|
||||||
'User-Agent': 'github.com/ad-m/github-push-action'
|
'User-Agent': 'github.com/ad-m/github-push-action'
|
||||||
@ -65,6 +66,5 @@ const main = async () => {
|
|||||||
|
|
||||||
main().catch(err => {
|
main().catch(err => {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
console.error(err.stack);
|
process.exit(-1);
|
||||||
process.exit(err.code || -1);
|
|
||||||
})
|
})
|
||||||
|
Reference in New Issue
Block a user