cybertron-utils
Version:
cybertron components manage
16 lines (15 loc) • 582 B
JavaScript
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;
}