infinitered / solidarity

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

shell scripts that pass in shell fail in solidarity shell #265

Open FrederickEngelhardt opened 3 years ago

FrederickEngelhardt commented 3 years ago

Hi, I'm trying to run a shell script to detect if you have nvm or fnm installed.

The first case passes (in both solidarity and shell) if you have fnm install or the .nvm folder exists at your home root.

The second case fails when running solidarity but passes when ran in shell.

To replicate this issue you will need to have nvm installed. https://github.com/nvm-sh/nvm

Example .solidarity json

{
  "$schema": "http://json.schemastore.org/solidaritySchema",
  "requirements": {
    "Node Manager (NVM | FNM)": [
      {
        "rule": "shell",
        "command": "if [ $(command -v fnm) ] || [ -d $HOME/.nvm ]; then echo true; fi;",
        "match": "true",
        "error": "NVM or FNM binaries are not detected"
      },
      {
        "rule": "shell",
        "command": "if [ $(command -v nvm) ]; then echo true; fi;",
        "match": "true",
        "error": "NVM not detected"
      }
    ],
  }
}
iegik commented 1 year ago

Use "cli" rule with "binary" property:

{
        "rule": "cli",
        "binary": "nvm"
      },