UNPKG

@s-ui/lint-reporters

Version:

Send lint errors and golden path metrics to DataDog

1 lines 1.48 kB
import _async_to_generator from"@swc/helpers/src/_async_to_generator.mjs";import _ts_generator from"@swc/helpers/src/_ts_generator.mjs";import{exec as execNode}from"child_process";import{promisify}from"util";import{HTTPSender}from"./Sender/HTTPSender";var exec=promisify(execNode);export var Reporter=function(){"use strict";function Reporter(){this.sender=HTTPSender.create()}var _proto=Reporter.prototype;_proto._isMaster=function _isMaster(){return _async_to_generator(function(){var branch;return _ts_generator(this,function(_state){switch(_state.label){case 0:return[4,exec("git rev-parse --abbrev-ref HEAD").catch(function(){return"UNKNOW_BRANCH"})];case 1:branch=_state.sent();if(typeof branch!=="string"){branch=branch.stdout}return[2,branch.trim()==="master"||branch.trim()==="main"]}})})()};_proto._getRepository=function _getRepository(){return _async_to_generator(function(){var url,cleanUrl,isHttp,ref,ref1,address;return _ts_generator(this,function(_state){switch(_state.label){case 0:return[4,exec("git config --get remote.origin.url").catch(function(){return"git@github.com:sui/remote-url.git"})];case 1:url=_state.sent();if(typeof url!=="string"){url=url.stdout}cleanUrl=url.trim().replace("\n","");isHttp=cleanUrl.startsWith("https://");if(isHttp){;return[2,(ref=cleanUrl.split("/")[4])==null?void 0:ref.replace(".git","")]}else{ref1=cleanUrl.split("@"),address=ref1[1];return[2,address.split("/")[1].replace(".git","")]}return[2]}})})()};return Reporter}();