Skip to content

Commit

Permalink
Allow plugin to be disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
bpinto committed Sep 24, 2020
1 parent 9c83605 commit 1c3ffa7
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
class JestWatchMasterPlugin {
constructor({ config } = {}) {
this.branch = 'master';
this.enabled = false;

if (config && config.branch) {
this.branch = config.branch;
}
Expand All @@ -9,12 +11,14 @@ class JestWatchMasterPlugin {
getUsageInfo() {
return {
key: 'm',
prompt: `test changes since ${this.branch}`,
prompt: `test changes since ${this.enabled ? 'last commit' : this.branch}`,
};
}

run(globalConfig, updateConfigAndRun) {
updateConfigAndRun({ mode: 'watch', changedSince: this.branch });
this.enabled = !this.enabled;

updateConfigAndRun({ mode: 'watch', changedSince: (this.enabled ? this.branch : null)});
return Promise.resolve();
}
}
Expand Down

0 comments on commit 1c3ffa7

Please sign in to comment.