Last active
October 31, 2022 03:12
-
-
Save abedolinger/013cdb3ee4873d53a4c2f68c1fa5678d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cp from 'child_process'; | |
const RED = '\x1b[31m'; | |
const RESET_COLOR = '\x1b[0m'; | |
const REQUIRED_POD_VERSION = '1.11.3'; | |
const check = () => { | |
if (process.env.GITHUB_ENV || process.env.CI) { | |
console.log('not checking Cocoapods version in CI'); | |
return 0; | |
} | |
console.log('Checking for correct Cocoapods version...'); | |
const CURRENT_POD_VERSION = | |
cp | |
.execSync('pod --version') | |
.toString() | |
.match(/\d+.\d+.\d+/)?.[0] || '0'; | |
if (CURRENT_POD_VERSION.includes(REQUIRED_POD_VERSION)) { | |
console.log('done'); | |
return 0; | |
} | |
console.log('\n---'); | |
console.log( | |
`${RED}ERROR: This project requires Cocoapods ${REQUIRED_POD_VERSION}. \`pod --version\` shows ${CURRENT_POD_VERSION}.${RESET_COLOR}`, | |
); | |
console.log(`Please run \`gem install cocoapods -v ${REQUIRED_POD_VERSION}\`.`); | |
if (CURRENT_POD_VERSION > REQUIRED_POD_VERSION) { | |
console.log('(Since the installed version is higher, run `gem uninstall cocoapods` first.)'); | |
} | |
console.log('---\n'); | |
return 1; | |
}; | |
const exitCode = check(); | |
process.exit(exitCode); | |
export { check }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Node script to check Cocoapods version. Used to keep team on same version