UNPKG

cybertron-utils

Version:
16 lines (15 loc) 582 B
const execSync = require( 'child_process' ).execSync; module.exports = function getGITUrl () { const gitMessage = execSync( 'git remote -v', { encoding: 'utf8' } ); const remoteList = gitMessage.split( '\n' ); let fetchUrl = null; for ( let i = 0; i < remoteList.length; i++ ) { if ( remoteList[i].includes( '(fetch)' ) && remoteList[i].includes( 'origin' ) ) { fetchUrl = remoteList[i].match( /(ssh|http|https).*\.git/ ); if ( fetchUrl ) { fetchUrl = fetchUrl[0]; } } } return fetchUrl; }