tasks/releasebuild.js
function gitRemote() {
      return function() {
        var deferred = Q.defer();
        Q.fcall(command('git remote', 'Git remote'))
          .then(function( data ) {
            if ( !data || !data.trim() ) {
              deferred.reject(new Error('Error in step [Git remote]. No remotes founds.'));
            }
            var remotes = data.trim().split('\n');
            if ( remotes.length == 1 ) {
              grunt.option('remote', remotes[0]);
              deferred.resolve(grunt.option('remote'));
            }
            else {
              remotes.forEach(function( item, index, list ) {
                list[index] = format('[%s]-%s', index + 1, item);
              });
              var resp = 0;
              grunt.log.writeln(format('%s ', '\n\nThere are more than 1 remote associate with this repo, please choose the one to push into.\n\n' + remotes.join('\n')));
              while ( isNaN(resp) || resp === 0 || resp > remotes.length ) {
                resp = readlinesync.question('\nYour choice?');
                if ( resp === '' ) {
                  grunt.option('remote', undefined);
                  throw new Error('Error in step [Git remote]. No response from user.');
                }
                resp = parseInt(resp);
              }
              grunt.option('remote', data.trim().split('\n')[resp-1]);//using original output
              deferred.resolve(grunt.option('remote'));
            }

          })
          .catch(function( err ) {
            grunt.option('remote', undefined);
            deferred.reject(err);
          });
        return deferred.promise;
      };
    }
function gitRemote() {
      return function() {
        var deferred = Q.defer();
        Q.fcall(command('git remote', 'Git remote'))
          .then(function( data ) {
            if ( !data || !data.trim() ) {
              deferred.reject(new Error('Error in step [Git remote]. No remotes founds.'));
            }
            var remotes = data.trim().split('\n');
            if ( remotes.length == 1 ) {
              grunt.option('remote', remotes[0]);
              deferred.resolve(grunt.option('remote'));
            }
            else {
              remotes.forEach(function( item, index, list ) {
                list[index] = format('[%s]-%s', index + 1, item);
              });
              var resp = 0;
              grunt.log.writeln(format('%s ', '\n\nThere are more than 1 remote associate with this repo, please choose the one to push into.\n\n' + remotes.join('\n')));
              while ( isNaN(resp) || resp === 0 || resp > remotes.length ) {
                resp = readlinesync.question('\nYour choice?');
                if ( resp === '' ) {
                  grunt.option('remote', undefined);
                  throw new Error('Error in step [Git remote]. No response from user.');
                }
                resp = parseInt(resp);
              }
              grunt.option('remote', data.trim().split('\n')[resp-1]);//using original output
              deferred.resolve(grunt.option('remote'));
            }

          })
          .catch(function( err ) {
            grunt.option('remote', undefined);
            deferred.reject(err);
          });
        return deferred.promise;
      };
    }
function gitRemote ( ) { return function ( ) { var deferred = Q . defer ( ) ; Q . fcall ( command ( 'git remote' , 'Git remote' ) ) . then ( function ( data ) { if ( ! data || ! data . trim ( ) ) { deferred . reject ( new Error ( 'Error in step [Git remote]. No remotes founds.' ) ) ; } var remotes = data . trim ( ) . split ( '\n' ) ; if ( remotes . length == 1 ) { grunt . option ( 'remote' , remotes [ 0 ] ) ; deferred . resolve ( grunt . option ( 'remote' ) ) ; } else { remotes . forEach ( function ( item , index , list ) { list [ index ] = format ( '[%s]-%s' , index + 1 , item ) ; } ) ; var resp = 0 ; grunt . log . writeln ( format ( '%s ' , '\n\nThere are more than 1 remote associate with this repo, please choose the one to push into.\n\n' + remotes . join ( '\n' ) ) ) ; while ( isNaN ( resp ) || resp === 0 || resp > remotes . length ) { resp = readlinesync . question ( '\nYour choice?' ) ; if ( resp === '' ) { grunt . option ( 'remote' , undefined ) ; throw new Error ( 'Error in step [Git remote]. No response from user.' ) ; } resp = parseInt ( resp ) ; } grunt . option ( 'remote' , data . trim ( ) . split ( '\n' ) [ resp - 1 ] ) ; //using original output deferred . resolve ( grunt . option ( 'remote' ) ) ; } } ) . catch ( function ( err ) { grunt . option ( 'remote' , undefined ) ; deferred . reject ( err ) ; } ) ; return deferred . promise ; } ; }
Retrieve the remote name
@returns {Function}
Retrieve the remote name