@@ -48,6 +48,7 @@ var isString = require( '@stdlib/assert/is-string' ).isPrimitive;
4848var removeFirst = require ( '@stdlib/string/remove-first' ) ;
4949var reFromString = require ( '@stdlib/utils/regexp-from-string' ) ;
5050var startsWith = require ( '@stdlib/string/starts-with' ) ;
51+ var substringAfterLast = require ( '@stdlib/string/substring-after-last' ) ;
5152var currentYear = require ( '@stdlib/time/current-year' ) ;
5253var namespaceDeps = require ( '@stdlib/_tools/pkgs/namespace-deps' ) ;
5354var depList = require ( '@stdlib/_tools/pkgs/dep-list' ) ;
@@ -476,16 +477,14 @@ function publish( pkg, clbk ) {
476477 pth = 'https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/' + pkg ;
477478
478479 dist = join ( mainDir , 'build' , '@stdlib' , distPkg ) ;
479- command = 'git ls-remote --tags --sort="v:refname" https://' + ENV . GITHUB_TOKEN + '@github.com/stdlib-js/' + distPkg + '.git | tail -n1 | sed \'s/.*\\///; s/[-a-z]*\\^{}//\' ' ;
480+ command = 'git ls-remote --tags --sort="v:refname" https://' + ENV . GITHUB_TOKEN + '@github.com/stdlib-js/' + distPkg + '.git' ;
480481 debug ( 'Executing command to retrieve last version: %s' , command ) ;
481482 try {
482483 command = shell ( command ) . toString ( ) ;
483- if ( contains ( command , 'not found' ) ) {
484- repoExists = false ;
485- } else {
486- repoExists = true ;
487- version = trim ( removeFirst ( command ) ) ; // Remove leading `v`...
488- }
484+ repoExists = true ;
485+ version = substringAfterLast ( command , '/' ) ;
486+ version = replace ( version , / [ - a - z . ] * \^ { } / , '' ) ;
487+ version = trim ( removeFirst ( version ) ) ; // Remove leading `v`...
489488 } catch ( error ) {
490489 console . error ( 'Encountered an error when attempting to retrieve the last version. Error: %s' , error . message ) ;
491490 repoExists = false ;
0 commit comments