-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Fix path to local http-proxy in examples. #1072
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 –– thanks!
There was a problem hiding this 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;
const prompts = require('prompts'); class JestWatchBranchPlugin { async run(globalConfig, updateConfigAndRun) {
} async _getBranches(rootDir) {
} module.exports = JestWatchBranchPlugin; |
Fixes path to http-proxy in two examples so that they can be run locally.