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

Fix path to local http-proxy in examples. #1072

Merged
merged 2 commits into from Aug 22, 2019
Merged

Fix path to local http-proxy in examples. #1072

merged 2 commits into from Aug 22, 2019

Conversation

kribblo
Copy link
Contributor

@kribblo kribblo commented Sep 29, 2016

Fixes path to http-proxy in two examples so that they can be run locally.

Copy link
Contributor

@indexzero indexzero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 –– thanks!

@indexzero indexzero merged commit c662f9e into http-party:master Aug 22, 2019
This was referenced Mar 17, 2021
Copy link

@pashabhn pashabhn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const prompts = require('prompts');
const { findRepos } = require('jest-changed-files');
const simpleGit = require('simple-git/promise');

class JestWatchBranchPlugin {
getUsageInfo() {
return {
key: 'b',
prompt: 'test changes since a given branch',
};
}

async run(globalConfig, updateConfigAndRun) {
const branches = await this._getBranches(globalConfig.rootDir);
const { branch } = await prompts({
type: 'select',
name: 'branch',
message: 'Which branch do you want to base off of?',
choices: branches,
});

updateConfigAndRun({ mode: 'watch', changedSince: branch });

process.stdin.setRawMode(true);
process.stdin.resume();

return true;

}

async _getBranches(rootDir) {
// findRepos return a set of git repos and a set of hg repos.
// It doesn't really make sense to use this plugin across different
// repositories, so we assume there's a single repository
// for rootDir by just getting the first one
const { git: roots } = await findRepos([rootDir]);

const [root] = Array.from(roots);

if (!root) {
  throw new Error('Unable to find git root');
}

const repo = simpleGit(root);

const { branches } = await repo.branch();

return Object.values(branches)
  .map(branch => ({
    ...branch,
    name: branch.name.replace(/^remotes\//, ''),
  }))
  .map(({ current, name }) => ({
    value: name,
    title: current ? `${name} (current branch)` : name,
  }));

}
}

module.exports = JestWatchBranchPlugin;

@pashabhn
Copy link

pashabhn commented May 5, 2022

const prompts = require('prompts');
const { findRepos } = require('jest-changed-files');
const simpleGit = require('simple-git/promise');

class JestWatchBranchPlugin {
getUsageInfo() {
return {
key: 'b',
prompt: 'test changes since a given branch',
};
}

async run(globalConfig, updateConfigAndRun) {
const branches = await this._getBranches(globalConfig.rootDir);
const { branch } = await prompts({
type: 'select',
name: 'branch',
message: 'Which branch do you want to base off of?',
choices: branches,
});

updateConfigAndRun({ mode: 'watch', changedSince: branch });

process.stdin.setRawMode(true);
process.stdin.resume();

return true;

}

async _getBranches(rootDir) {
// findRepos return a set of git repos and a set of hg repos.
// It doesn't really make sense to use this plugin across different
// repositories, so we assume there's a single repository
// for rootDir by just getting the first one
const { git: roots } = await findRepos([rootDir]);

const [root] = Array.from(roots);

if (!root) {
  throw new Error('Unable to find git root');
}

const repo = simpleGit(root);

const { branches } = await repo.branch();

return Object.values(branches)
  .map(branch => ({
    ...branch,
    name: branch.name.replace(/^remotes\//, ''),
  }))
  .map(({ current, name }) => ({
    value: name,
    title: current ? `${name} (current branch)` : name,
  }));

}
}

module.exports = JestWatchBranchPlugin;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants