From 2f951ef5cd3d241fe3d8b8b13f23a2fbf73849de Mon Sep 17 00:00:00 2001 From: Shivam Mathur Date: Sat, 30 Nov 2019 03:29:00 +0530 Subject: [PATCH] Use Homebrew for PHP 7.4 on macOS --- __tests__/utils.test.ts | 9 +-------- dist/index.js | 14 +------------- src/scripts/darwin.sh | 5 ++++- src/utils.ts | 30 ++++-------------------------- 4 files changed, 10 insertions(+), 48 deletions(-) diff --git a/__tests__/utils.test.ts b/__tests__/utils.test.ts index 7560b48c..b28e06b7 100644 --- a/__tests__/utils.test.ts +++ b/__tests__/utils.test.ts @@ -60,10 +60,6 @@ describe('Utils tests', () => { }); it('checking readScripts', async () => { - const rc: string = fs.readFileSync( - path.join(__dirname, '../src/scripts/7.4.sh'), - 'utf8' - ); const darwin: string = fs.readFileSync( path.join(__dirname, '../src/scripts/darwin.sh'), 'utf8' @@ -76,15 +72,12 @@ describe('Utils tests', () => { path.join(__dirname, '../src/scripts/win32.ps1'), 'utf8' ); - expect(await utils.readScript('darwin.sh', '7.4', 'darwin')).toBe(rc); + expect(await utils.readScript('darwin.sh', '7.4', 'darwin')).toBe(darwin); expect(await utils.readScript('darwin.sh', '7.3', 'darwin')).toBe(darwin); expect(await utils.readScript('linux.sh', '7.4', 'linux')).toBe(linux); expect(await utils.readScript('linux.sh', '7.3', 'linux')).toBe(linux); expect(await utils.readScript('win32.ps1', '7.4', 'win32')).toBe(win32); expect(await utils.readScript('win32.ps1', '7.3', 'win32')).toBe(win32); - expect(await utils.readScript('fedora.sh', '7.3', 'fedora')).toContain( - 'Platform fedora is not supported' - ); }); it('checking writeScripts', async () => { diff --git a/dist/index.js b/dist/index.js index 9967fae5..705cdfc8 100644 --- a/dist/index.js +++ b/dist/index.js @@ -810,19 +810,7 @@ exports.addLog = addLog; */ function readScript(filename, version, os_version) { return __awaiter(this, void 0, void 0, function* () { - switch (os_version) { - case 'darwin': - switch (version) { - case '7.4': - return fs.readFileSync(path.join(__dirname, '../src/scripts/7.4.sh'), 'utf8'); - } - return fs.readFileSync(path.join(__dirname, '../src/scripts/' + filename), 'utf8'); - case 'linux': - case 'win32': - return fs.readFileSync(path.join(__dirname, '../src/scripts/' + filename), 'utf8'); - default: - return yield log('Platform ' + os_version + ' is not supported', os_version, 'error'); - } + return fs.readFileSync(path.join(__dirname, '../src/scripts/' + filename), 'utf8'); }); } exports.readScript = readScript; diff --git a/src/scripts/darwin.sh b/src/scripts/darwin.sh index 91f7902d..176a262d 100644 --- a/src/scripts/darwin.sh +++ b/src/scripts/darwin.sh @@ -17,12 +17,15 @@ add_log() { fi } +step_log "Setup PHP and Composer" version=$1 export HOMEBREW_NO_INSTALL_CLEANUP=TRUE if [ "$1" = "5.6" ] || [ "$1" = "7.0" ]; then brew tap exolnet/homebrew-deprecated >/dev/null 2>&1 fi -step_log "Setup PHP and Composer" +if [ "$1" = "7.4" ]; then + brew update >/dev/null 2>&1 +fi brew install php@"$1" composer >/dev/null 2>&1 brew link --force --overwrite php@"$1" >/dev/null 2>&1 ini_file=$(php -d "date.timezone=UTC" --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g") diff --git a/src/utils.ts b/src/utils.ts index d9a56161..23c0327f 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -173,32 +173,10 @@ export async function readScript( version: string, os_version: string ): Promise { - switch (os_version) { - case 'darwin': - switch (version) { - case '7.4': - return fs.readFileSync( - path.join(__dirname, '../src/scripts/7.4.sh'), - 'utf8' - ); - } - return fs.readFileSync( - path.join(__dirname, '../src/scripts/' + filename), - 'utf8' - ); - case 'linux': - case 'win32': - return fs.readFileSync( - path.join(__dirname, '../src/scripts/' + filename), - 'utf8' - ); - default: - return await log( - 'Platform ' + os_version + ' is not supported', - os_version, - 'error' - ); - } + return fs.readFileSync( + path.join(__dirname, '../src/scripts/' + filename), + 'utf8' + ); } /**