chore: move getCurrentBranch to a util file (#15921)
* chore: move getCurrentBranch to a util file * fix import
This commit is contained in:
		
					parent
					
						
							
								a1a431eb87
							
						
					
				
			
			
				commit
				
					
						d3c58ea48c
					
				
			
		
					 4 changed files with 30 additions and 53 deletions
				
			
		|  | @ -3,7 +3,7 @@ const fs = require('fs') | |||
| const path = require('path') | ||||
| const childProcess = require('child_process') | ||||
| const GitHubApi = require('github') | ||||
| const { GitProcess } = require('dugite') | ||||
| const { getCurrentBranch } = require('./lib/utils.js') | ||||
| const request = require('request') | ||||
| const semver = require('semver') | ||||
| const rootPackageJson = require('../package.json') | ||||
|  | @ -162,21 +162,3 @@ new Promise((resolve, reject) => { | |||
|     console.error(`Error: ${err}`) | ||||
|     process.exit(1) | ||||
|   }) | ||||
| 
 | ||||
| async function getCurrentBranch () { | ||||
|   const gitDir = path.resolve(__dirname, '..') | ||||
|   console.log(`Determining current git branch`) | ||||
|   const gitArgs = ['rev-parse', '--abbrev-ref', 'HEAD'] | ||||
|   const branchDetails = await GitProcess.exec(gitArgs, gitDir) | ||||
|   if (branchDetails.exitCode === 0) { | ||||
|     const currentBranch = branchDetails.stdout.trim() | ||||
|     console.log(`Successfully determined current git branch is ` + | ||||
|       `${currentBranch}`) | ||||
|     return currentBranch | ||||
|   } else { | ||||
|     const error = GitProcess.parseError(branchDetails.stderr) | ||||
|     console.log(`Could not get details for the current branch,
 | ||||
|       error was ${branchDetails.stderr}`, error)
 | ||||
|     process.exit(1) | ||||
|   } | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Shelley Vohr
				Shelley Vohr