From c188004a5280827be087dc4ce16f7775660a7159 Mon Sep 17 00:00:00 2001 From: Shivam Mathur Date: Sat, 28 Nov 2020 14:59:24 +0530 Subject: [PATCH] Fix macos --- __tests__/utils.test.ts | 23 ++++++++++++----------- src/scripts/darwin.sh | 6 +++--- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/__tests__/utils.test.ts b/__tests__/utils.test.ts index b7b23430..3e3b240d 100644 --- a/__tests__/utils.test.ts +++ b/__tests__/utils.test.ts @@ -42,11 +42,12 @@ describe('Utils tests', () => { it('checking asyncForEach', async () => { const array: Array = ['a', 'b', 'c']; let concat = ''; - await utils.asyncForEach(array, async function ( - str: string - ): Promise { - concat += str; - }); + await utils.asyncForEach( + array, + async function (str: string): Promise { + concat += str; + } + ); expect(concat).toBe('abc'); }); @@ -83,12 +84,12 @@ describe('Utils tests', () => { const runner_dir: string = process.env['RUNNER_TOOL_CACHE'] || ''; const script_path: string = path.join(runner_dir, 'test.sh'); await utils.writeScript('test.sh', testString); - await fs.readFile(script_path, function ( - error: Error | null, - data: Buffer - ) { - expect(testString).toBe(data.toString()); - }); + await fs.readFile( + script_path, + function (error: Error | null, data: Buffer) { + expect(testString).toBe(data.toString()); + } + ); await cleanup(script_path); }); diff --git a/src/scripts/darwin.sh b/src/scripts/darwin.sh index 36c42773..0647905e 100644 --- a/src/scripts/darwin.sh +++ b/src/scripts/darwin.sh @@ -271,10 +271,10 @@ setup_php() { export HOMEBREW_NO_INSTALL_CLEANUP=TRUE brew tap --shallow shivammathur/homebrew-php update_dependencies - if brew list php@"$version" 2>/dev/null | grep -q "Error" && [ "$action" != "upgrade" ]; then - brew unlink php@"$version" + if ! [[ "$(find "$(brew --cellar)"/php/ -maxdepth 1 -name "$version*" | wc -l 2>/dev/null)" -eq 0 ]] && [ "$action" != "upgrade" ]; then + brew unlink shivammathur/php/php@"$version" else - brew "$action" shivammathur/php/php@"$version" + brew upgrade "shivammathur/php/php@$version" 2>/dev/null || brew install "shivammathur/php/php@$version" fi brew link --force --overwrite php@"$version" }