infinitered / solidarity

Solidarity is an environment checker for project dependencies across multiple machines.
https://infinitered.github.io/solidarity/
MIT License
639 stars 48 forks source link

Shell Rule #133

Closed skellock closed 6 years ago

skellock commented 6 years ago

How about a rule that allows you to run an arbitrary command and test it's output?

Simple

{
  "rule": "shell",
  "command": "mix escript",
  "match": "No escripts currently installed.",
  "error": "No escripts allowed even though I don't know what they are."
}

Advanced

{
  "rule": "shell",
  "command": "ruby -e 'puts RUBY_RELEASE_DATE'",
  "match": "-([0-9][0-9])-",
  "as": "number",
  "check": "x >= 11 or x <= 3",
  "error": "Ruby must have been released while it was snowing."
}

Another Advanced

{
  "rule": "shell",
  "command": "mix deps.tree",
  "check": "exit == 0",
  "error": "Unable to list dependencies, you and/or your mix.exs is insane."
}

Why?

This is a good short-term rule.

It allows some of what people want in #87 (minus the "rewrite this in a compiled language") and #107 (minus the support snapshots & custom js plugins).

I think it'll give people enough flexibility with adding custom rules without needing to write any js.

Thoughts?

I'd be up doing this work if you'd like.

GantMan commented 6 years ago

I love this rule!

I think it's a great short-term solution. And it's simple and clean.

Only nit I have is checking for the exit code exclusively takes the check spot. I'd rather have check always be for output, but a separate prop for those who want to check the exit code, like "exitCode": 0

I think it would be an epic add, plz add!