@ra3orblade/swarm 0.13.0 → 0.13.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -196,22 +196,26 @@ function otherLiveInSameTree(current, sessions, now, withinMs = LIVE_WINDOW_MS)
196
196
  }
197
197
  return null;
198
198
  }
199
+ var GIT_GLOBAL_OPTS = "(?:\\s+(?:-C\\s+\\S+|-c\\s+\\S+|--git-dir(?:=|\\s+)\\S+|--work-tree(?:=|\\s+)\\S+|--namespace(?:=|\\s+)\\S+|--no-pager|--paginate|--bare|--literal-pathspecs|--exec-path(?:=\\S+)?))*";
200
+ function gitVerb(verb, tail) {
201
+ return new RegExp(`\\bgit${GIT_GLOBAL_OPTS}\\s+${verb}${tail}`);
202
+ }
199
203
  function isBroadStage(cmd) {
200
204
  const c = cmd.trim();
201
- if (/\bgit\s+add\s+(-A\b|--all\b|\.(\s|$))/.test(c))
205
+ if (gitVerb("add", "\\s+(-A\\b|--all\\b|\\.(\\s|$))").test(c))
202
206
  return true;
203
- if (/\bgit\s+commit\b[^|&;]*\s-[a-zA-Z]*a/.test(c))
207
+ if (gitVerb("commit", "\\b[^|&;]*\\s-[a-zA-Z]*a").test(c))
204
208
  return true;
205
- if (/\bgit\s+add\s*$/.test(c))
209
+ if (gitVerb("add", "\\s*$").test(c))
206
210
  return true;
207
211
  return false;
208
212
  }
209
213
  function isDestructiveGit(cmd) {
210
214
  const c = cmd.trim();
211
- return /\bgit\s+reset\s+[^|&;]*--hard\b/.test(c) || /\bgit\s+checkout\s+(--\s+)?\.(\s|$)/.test(c) || /\bgit\s+checkout\s+-f\b/.test(c) || /\bgit\s+restore\s+(--\s+)?\.(\s|$)/.test(c) || /\bgit\s+clean\s+[^|&;]*-[a-zA-Z]*f/.test(c) || /\bgit\s+stash\s+(drop|clear)\b/.test(c) || /\bgit\s+branch\s+[^|&;]*-[a-zA-Z]*D/.test(c);
215
+ return gitVerb("reset", "\\s+[^|&;]*--hard\\b").test(c) || gitVerb("checkout", "\\s+(--\\s+)?\\.(\\s|$)").test(c) || gitVerb("checkout", "\\s+-f\\b").test(c) || gitVerb("restore", "\\s+(--\\s+)?\\.(\\s|$)").test(c) || gitVerb("clean", "\\s+[^|&;]*-[a-zA-Z]*f").test(c) || gitVerb("stash", "\\s+(drop|clear)\\b").test(c) || gitVerb("branch", "\\s+[^|&;]*-[a-zA-Z]*D").test(c);
212
216
  }
213
217
  function isPatternKill(cmd) {
214
- return /\bpkill\s+-f\b/.test(cmd) || /\bpgrep\s+-f\b[^|]*\|\s*[^|]*\bkill\b/.test(cmd);
218
+ return /\bpkill\s+(-[a-zA-Z]*f\b|--full\b)/.test(cmd) || /\bkillall\b/.test(cmd) || /\bpgrep\s+(-[a-zA-Z]*f\b|--full\b)[^|]*\|\s*[^|]*\bkill\b/.test(cmd);
215
219
  }
216
220
  function killedPorts(cmd) {
217
221
  const ports = new Set;