@git-lazy/util
TypeScript icon, indicating that this package has built-in type declarations

1.0.43 • Public • Published

@git-lazy/util

@git-lazy core lib and a better cross spawn for git
npm install @git-lazy/util
import { crossSpawnSync, crossSpawnAsync, SpawnOptions, checkGitOutput } from '@git-lazy/util/spawn/git';
import { notEmptyString, debug } from '@git-lazy/util';
import { crossSpawnOutput, filterCrossSpawnArgv } from '@git-lazy/util/spawn/util';

export function localBranchList(REPO_PATH: string): string[]
{
	let cp = crossSpawnSync('git', [
		'branch',
		'--list',
		'--format=%(refname)',
	], {
		cwd: REPO_PATH,
	});

	cp = checkGitOutput(cp);

	if (!cp.error)
	{
		let out = crossSpawnOutput(cp.stdout, {
			clearEol: true,
			stripAnsi: true,
		});

		let ls = out.split(/\n/).map(function (s)
		{
			return s.trim();
		});

		if (ls.length)
		{
			return ls
		}
	}

	debug.enabled && debug(crossSpawnOutput(cp.output));

	return [];
}

Readme

Keywords

none

Package Sidebar

Install

npm i @git-lazy/util

Weekly Downloads

112

Version

1.0.43

License

ISC

Unpacked Size

25 kB

Total Files

30

Last publish

Collaborators

  • bluelovers