Use Homebrew for PHP 7.4 on macOS

This commit is contained in:
Shivam Mathur 2019-11-30 03:29:00 +05:30
parent 5a081357b4
commit 2f951ef5cd
No known key found for this signature in database
GPG Key ID: 3E13E4C8591ACC2A
4 changed files with 10 additions and 48 deletions

View File

@ -60,10 +60,6 @@ describe('Utils tests', () => {
}); });
it('checking readScripts', async () => { it('checking readScripts', async () => {
const rc: string = fs.readFileSync(
path.join(__dirname, '../src/scripts/7.4.sh'),
'utf8'
);
const darwin: string = fs.readFileSync( const darwin: string = fs.readFileSync(
path.join(__dirname, '../src/scripts/darwin.sh'), path.join(__dirname, '../src/scripts/darwin.sh'),
'utf8' 'utf8'
@ -76,15 +72,12 @@ describe('Utils tests', () => {
path.join(__dirname, '../src/scripts/win32.ps1'), path.join(__dirname, '../src/scripts/win32.ps1'),
'utf8' '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('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.4', 'linux')).toBe(linux);
expect(await utils.readScript('linux.sh', '7.3', '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.4', 'win32')).toBe(win32);
expect(await utils.readScript('win32.ps1', '7.3', '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 () => { it('checking writeScripts', async () => {

14
dist/index.js vendored
View File

@ -810,19 +810,7 @@ exports.addLog = addLog;
*/ */
function readScript(filename, version, os_version) { function readScript(filename, version, os_version) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
switch (os_version) { return fs.readFileSync(path.join(__dirname, '../src/scripts/' + filename), 'utf8');
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');
}
}); });
} }
exports.readScript = readScript; exports.readScript = readScript;

View File

@ -17,12 +17,15 @@ add_log() {
fi fi
} }
step_log "Setup PHP and Composer"
version=$1 version=$1
export HOMEBREW_NO_INSTALL_CLEANUP=TRUE export HOMEBREW_NO_INSTALL_CLEANUP=TRUE
if [ "$1" = "5.6" ] || [ "$1" = "7.0" ]; then if [ "$1" = "5.6" ] || [ "$1" = "7.0" ]; then
brew tap exolnet/homebrew-deprecated >/dev/null 2>&1 brew tap exolnet/homebrew-deprecated >/dev/null 2>&1
fi 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 install php@"$1" composer >/dev/null 2>&1
brew link --force --overwrite php@"$1" >/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") ini_file=$(php -d "date.timezone=UTC" --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")

View File

@ -173,32 +173,10 @@ export async function readScript(
version: string, version: string,
os_version: string os_version: string
): Promise<string> { ): Promise<string> {
switch (os_version) { return fs.readFileSync(
case 'darwin': path.join(__dirname, '../src/scripts/' + filename),
switch (version) { 'utf8'
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'
);
}
} }
/** /**