How to use getCurrentBranchName method in ts-auto-mock

Best JavaScript code snippet using ts-auto-mock

utils.js

Source:utils.js Github

copy

Full Screen

...43}44/**45 * @returns {string} 현재 브랜치명46 */47function getCurrentBranchName(){48 return execSync('git rev-parse --abbrev-ref HEAD', options.encodingOption).replace(/\n/, '');49}50/**51 * @returns {string} 현재 브랜치 헤드 커밋정보 [커밋번호][커밋시점]52 */53function getCurrnetBranchHeadInfo(){54 return execSync('git log ' + getCurrentBranchName() + ' --pretty=format:\"[%h][%ai]\" -n 1', options.encodingOption).replace(/\n/, '');55}56/**57 * 커밋하지 않은 내역이 있으면 빌드 종료58 */59function checkUncommitedChanges(){60 var bHasChanges = execSync('git status -s', options.encodingOption).replace(/[\s\n]/g, "").length > 0;61 if(bHasChanges){62 console.log("커밋하지 않은 수정사항이 있습니다. 확인해주세요.\n");63 execSync('git status -s', options.stdioOption);64 process.exit();65 }66}67/**68 * 푸쉬하지 않은 내역이 있으면 빌드 종료69 */70function checkUnpushedCommits(){71 var currentBranchName = getCurrentBranchName();72 var bHasCommits = execSync('git log --oneline origin/' + currentBranchName + '..HEAD -1', options.encodingOption).replace(/[\s\n]/g, '').length > 0;73 if(bHasCommits){74 console.log("푸쉬하지 않은 커밋이 있습니다. 확인해주세요.\n");75 execSync('git log --oneline origin/' + currentBranchName + '..HEAD', options.stdioOption);76 process.exit();77 }78}79/**80 * @returns {string} 현재 git의 루트 디렉토리 위치81 */82function getGitRootAbsolutePath(){83 return execSync('git rev-parse --show-toplevel', options.encodingOption).replace(/\n/, '');84}85/**86 * @param sTargetPath cdn 디렉토리 명칭87 * @returns {string} cdn 디렉토리 상대경로88 */89function getRelativeTargetPath(sTargetPath){90 return path.join(path.relative(process.cwd(), getGitRootAbsolutePath()), sTargetPath);91}92/**93 * @param dir 대상 디렉토리94 * @param aFilesPath 재귀를 위해 사용하는 파일 배열95 * @returns {Array} 디렉토리의 파일목록96 */97function getFileList(dir, aFilesPath){98 var aFilesPath = aFilesPath || [];99 fs.readdirSync(dir).forEach(function(list){100 var listpath = path.join(dir, list);101 var bIsDirectory = fs.statSync(listpath).isDirectory();102 if(bIsDirectory){103 getFileList(listpath, aFilesPath);104 }else{105 aFilesPath.push(listpath);106 }107 });108 return aFilesPath;109}110/**111 * @param dir 대상 디렉토리112 * @param ext .이 포함된 확장자 (.scss, .html)113 * @returns {Array} 디렉토리의 파일목록114 */115function getFileListByExt(dir, ext){116 return fs.readdirSync(dir)117 .filter((sub) => path.extname(sub) === ext);118}119/**120 * @param dir 대상 디렉토리121 * @returns {Array} 디렉토리의 하위 디렉토리 목록122 */123function getSubdirList(dir){124 return fs.readdirSync(dir)125 .filter((sub) => fs.statSync(path.join(dir, sub)).isDirectory());126}127/**128 * 프로모션 sun 배포129 * @param {string} sDeployBranch 리소스를 추가할 브랜치 admin_tmon_common130 * @param {string} sTargetDir 대상 디렉토리131 * @param {object} files 파일경로를 키로 하고 버퍼를 값으로 하는 객체132 * @param {string} targetPath 프로모션 기준의 대상 디렉토리의 상대경로133 */134function deployPromotionToSun(sDeployBranch, sTargetDir, files, targetPath){135 var currentBranchName = getCurrentBranchName(),136 currentBranchHeadInfo = getCurrnetBranchHeadInfo(),137 aFiles = Object.keys(files),138 sAllFilepath = aFiles.map(function(file){139 return path.join(targetPath, file);140 }).join(' ');141 execSync('git checkout ' + sDeployBranch, options.stdioOption);142 execSync('git pull', options.stdioOption);143 aFiles.forEach(function(filepath){144 var fullpath = path.join(targetPath, filepath);145 mkdirSync(fullpath);146 fs.writeFileSync(fullpath, files[filepath]);147 });148 execSync('git add ' + sAllFilepath, options.stdioOption);149 execSync('git commit -m \'[SUN][promotion][' + sTargetDir + '][' + currentBranchName + ']' + currentBranchHeadInfo + '\'', options.stdioOption);...

Full Screen

Full Screen

git.js

Source:git.js Github

copy

Full Screen

...17runCommand('./parent.sh').then((result) => {18 console.log('RE SULT', [result]);19});20// The current !!21getCurrentBranchName().then((result) => {22 console.log('The current', [result], result.length);23});24// has new files25}26// Diff (unstaged work)!!27runCommand ('git diff').then((result) => {28 console.log('Has UnStagedWork?', !!result.length);29}).catch((error) => {30 console.log('UnstagdWorkError', error);31});32// Diff cached (changes to be commited)33runCommand('git diff --cached').then((result) => {34 console.log('has CachedUnstagedWork?', !!result.length);35}).catch((error) => {36 console.log('CachedUnstagedWorkError', error);37});38// Has new files?39runCommand('git ls-files . --exclude-standard --others').then((result) => {40 console.log('Has new files?', !!result.length);41});42// Has unpushed commits? (only if remote branch exists)43const hasUnpushedCommits = () => getCurrentBranchName().then(currentBranch => {44 // has un-pushed commits with the remote branch?45 return runCommand(`git log origin/${currentBranch}...HEAD`).then((changes) => {46 return !!changes.length;47 })48});49// Does remote branch exists?50const remoteBranchExists = () => getCurrentBranchName().then((branchName) => (51 runCommand(`git ls-remote --heads origin ${branchName}`)52)).then((output) => !!output.length);53remoteBranchExists().then((exists) => {54 console.log('Branch exists?', exists);55 if (exists) {56 hasUnpushedCommits().then((result) => {57 console.log('Has UnPushedCommits?', result);58 })59 }60})61// has un-pushed commits.62// runCommand('git status').then((result) => {63// console.log('Status', result.length);64// }).catch((error) => {...

Full Screen

Full Screen

checkBranch.js

Source:checkBranch.js Github

copy

Full Screen

...12 * @function checkIsMaster 检测当前分支是不是master13 * @return {boolean}14 */15async function checkIsMasterOrRelease () {16 const branch = await getCurrentBranchName()17 console.log('current branch is', branch)18 const bool = branch === 'master' || branch.indexOf('release/') === 019 if (bool) {20 console.log(chalk.red('\n【操作错误】禁止在 master 和 release 分支上,进行 git commit 和 git push \n'))21 }22 return bool23}24/**25 * @function checkHasOriginMaster 检查远程是否master分支26 * @return {boolean}27 */28async function checkHasOriginMaster () {29 const res = await getStdout('git ls-remote --heads origin master | wc -l')30 const bool = res.trim() === '1'...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1import { getCurrentBranchName } from 'ts-auto-mock';2console.log(getCurrentBranchName());3import { getCurrentBranchName } from 'ts-auto-mock';4console.log(getCurrentBranchName());5jest.mock('ts-auto-mock');6jest.mock('ts-auto-mock', () => {7 return {8 getCurrentBranchName: jest.fn().mockReturnValue('master'),9 };10});11jest.mock('ts-auto-mock', () => {12 return {13 getCurrentBranchName: jest.fn().mockResolvedValue('master'),14 };15});16jest.mock('ts-auto-mock', () => {17 return {18 getCurrentBranchName: jest.fn().mockRejectedValue(new Error('master')),19 };20});

Full Screen

Using AI Code Generation

copy

Full Screen

1import {getCurrentBranchName} from 'ts-auto-mock';2console.log(getCurrentBranchName());3import {getCurrentBranchName} from 'ts-auto-mock';4console.log(getCurrentBranchName());5{6 "compilerOptions": {7 },8}9{10 "compilerOptions": {11 },12}13"test": {14 "options": {15 }16}17module.exports = function (config) {18 config.set({19 require('karma-jasmine'),20 require('k

Full Screen

Using AI Code Generation

copy

Full Screen

1import { getCurrentBranchName } from 'ts-auto-mock';2const branchName = getCurrentBranchName();3console.log(branchName);4import { getCurrentBranchName } from 'ts-auto-mock';5const branchName = getCurrentBranchName();6console.log(branchName);

Full Screen

Using AI Code Generation

copy

Full Screen

1import { getCurrentBranchName } from 'ts-auto-mock';2const currentBranch = getCurrentBranchName();3console.log(currentBranch);4import { getCurrentBranchName } from 'ts-auto-mock';5const currentBranch = getCurrentBranchName();6console.log(currentBranch);

Full Screen

Using AI Code Generation

copy

Full Screen

1const tsAutoMock = require('ts-auto-mock');2tsAutoMock.getCurrentBranchName().then((branchName) => {3 console.log(branchName);4});5const tsAutoMock = require('ts-auto-mock');6tsAutoMock.getCurrentBranchName().then((branchName) => {7 console.log(branchName);8});

Full Screen

Using AI Code Generation

copy

Full Screen

1import { getCurrentBranchName } from 'ts-auto-mock';2console.log(getCurrentBranchName());3import { getCurrentBranchName } from 'ts-auto-mock';4console.log(getCurrentBranchName());5import 'ts-auto-mock';6"paths": {7}

Full Screen

Using AI Code Generation

copy

Full Screen

1import { getCurrentBranchName } from 'ts-auto-mock';2const branchName = getCurrentBranchName();3console.log(branchName);4import { getCurrentBranchName } from 'ts-auto-mock';5const branchName = getCurrentBranchName();6console.log(branchName);7import { getCurrentBranchName } from 'ts-auto-mock';8const branchName = getCurrentBranchName();9console.log(branchName);10import { getCurrentBranchName } from 'ts-auto-mock';11const branchName = getCurrentBranchName();12console.log(branchName);

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run ts-auto-mock automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful