Yankees’ path to Gerrit Cole had many anxious moments