Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A more opinionated entry point #166

Open
shiftkey opened this issue Feb 21, 2018 · 0 comments
Open

A more opinionated entry point #166

shiftkey opened this issue Feb 21, 2018 · 0 comments
Milestone

Comments

@shiftkey
Copy link
Member

shiftkey commented Feb 21, 2018

The infamous @paulcbetts tweeted this at me:

You should steal https://github.com/surf-build/surf/pull/75/files#diff-c7ba9741682b21471b9c2842c396f106R18 for Dugite, it's a bit more Ergonomic of a function

Here's the snippet:

let askPassPath: string;
export async function git(args: string[], cwd: string, token?: string): Promise<string> {
  let ourToken = token || process.env.GITHUB_TOKEN;
  if (!askPassPath) {
    askPassPath = findActualExecutable('git-askpass-env', []).cmd;
  }

  d(`Actually using token! ${ourToken}`);
  process.env.GIT_ASKPASS = askPassPath;
  process.env.GIT_ASKPASS_USER = ourToken;
  process.env.GIT_ASKPASS_PASSWORD = 'x-oauth-basic';

  d(`Running command: git ${args.join(' ')} in ${cwd}`);
  let ret = await GitProcess.exec(args, cwd);
  if (ret.exitCode !== 0) {
    throw new Error(`Failed with exit code ${ret.exitCode}\n${ret.stderr}`);
  }

  return ret.stdout.trim();
}

Why? He followed up:

But like, trim is an easy win, and failed exit codes should definitely == failed Promise

This would be neat to help with the "Hello world!" sorts of examples that people might want to use this library for.

There's a few things around the internals and API surface that I'd like to get to around Other Priorities™ but if someone wants to have a go at this I'm happy to review and guide the actual implementation and where this fits.

@shiftkey shiftkey added this to the 2.0 milestone Nov 20, 2018
@shiftkey shiftkey self-assigned this Nov 22, 2018
@shiftkey shiftkey removed their assignment Jun 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant