JSPM

  • Created
  • Published
  • Downloads 508
  • Score
    100M100P100Q92724F
  • License ISC

@git-lazy core lib and a better cross spawn for git

Package Exports

  • @git-lazy/util
  • @git-lazy/util/index.js
  • @git-lazy/util/spawn/data
  • @git-lazy/util/spawn/data.js
  • @git-lazy/util/spawn/git
  • @git-lazy/util/spawn/git.js
  • @git-lazy/util/spawn/util
  • @git-lazy/util/spawn/util.js
  • @git-lazy/util/util/index
  • @git-lazy/util/util/index.js
  • @git-lazy/util/util/match
  • @git-lazy/util/util/match.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@git-lazy/util) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@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 [];
}