非常に単純なpre-commitスクリプトを作成しました:-
#!/usr/bin/env sh
# Run tests
npm test
if [ $? -ne 0 ]; then
echo "Tests failed. Aborting.."
exit 1
fi
exit 0
git commit
コマンドラインで(テストに失敗して)実行すると、期待される出口1がメッセージとともに表示されますTests failed. Aborting..
。
ただし、GitHub for Macを使用すると、次のようになります。
.git/hooks/pre-commit: line 5: npm: command not found
Tests failed. Aborting..
(256)
npm
GitHub for Macが使用している実行環境では利用できないのではないかと推測していますが、これを修正する方法を模索していると、頭がおかしくなります。