Add BATS regression test setup
Fixes #49.
This adds a BATS-based test setup for node-reinstall with CI wiring:
make testrunsbash -nplus the BATS suite.travis.ymlinstalls bats-core and runs the test target, matching the original request- GitHub Actions runs the same suite on Ubuntu and macOS for current hosted CI coverage
- Tests cover safe CLI exits plus
--forcereinstall flows through temporary stubs forsudo,rm,npm,curl,nvm, andnave
The BATS coverage also caught two small portability issues in the existing script:
grep -E "\d"does not portably match digits, so the nvm release regex now uses[0-9]- global module capture now runs
basenameonce per path and drops only exactlib/npmentries
Local verification:
git clone --depth 1 https://github.com/bats-core/bats-core.git /tmp/bats-core-node-reinstall
PATH="/tmp/bats-core-node-reinstall/bin:$PATH" make test
Result: 8 tests passing.
For the issue bounty, PayPal payout can go to [email protected].
Follow-up pushed: added a regression for --nvm-latest so it uses the master installer path without querying the latest release API, plus the matching one-line fix. Local validation now passes with PATH="/tmp/bats-core-node-reinstall/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/Library/Frameworks/Python.framework/Versions/3.10/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/opt/pmk/env/global/bin:/Library/Apple/usr/bin:/Users/cultofrozen/.local/bin:/Users/cultofrozen/.codex/tmp/arg0/codex-arg0bpxqP6:/Users/cultofrozen/.opencode/bin:/Users/cultofrozen/.bun/bin:/Users/cultofrozen/.claude-view/bin:/Applications/Codex.app/Contents/Resources" make test (9 BATS tests).