mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-22 20:01:06 +07:00
Only check castor version if castor.php is present
This commit is contained in:
parent
c63f07d82e
commit
9d529a72e0
@ -1,3 +1,4 @@
|
|||||||
|
import fs = require('fs');
|
||||||
import * as tools from '../src/tools';
|
import * as tools from '../src/tools';
|
||||||
|
|
||||||
interface IData {
|
interface IData {
|
||||||
@ -533,7 +534,7 @@ describe('Tools tests', () => {
|
|||||||
${'latest'} | ${'darwin'} | ${'releases/latest/download/castor.darwin-amd64.phar'}
|
${'latest'} | ${'darwin'} | ${'releases/latest/download/castor.darwin-amd64.phar'}
|
||||||
${'0.5.1'} | ${'darwin'} | ${'releases/download/v0.5.1/castor.darwin-amd64.phar'}
|
${'0.5.1'} | ${'darwin'} | ${'releases/download/v0.5.1/castor.darwin-amd64.phar'}
|
||||||
${'latest'} | ${'win32'} | ${'releases/latest/download/castor.windows-amd64.phar'}
|
${'latest'} | ${'win32'} | ${'releases/latest/download/castor.windows-amd64.phar'}
|
||||||
${'0.5.1'} | ${'win32'} | ${'releases/download/v0.5.1/castor.windows-amd64.phar'}
|
${'0.5.1'} | ${'win32'} | ${'releases/download/v0.5.1/castor.windows-amd64.phar castor -V'}
|
||||||
${'latest'} | ${'openbsd'} | ${'Platform openbsd is not supported'}
|
${'latest'} | ${'openbsd'} | ${'Platform openbsd is not supported'}
|
||||||
`('checking addCastor: $version, $os', async ({version, os, uri}) => {
|
`('checking addCastor: $version, $os', async ({version, os, uri}) => {
|
||||||
const data = getData({
|
const data = getData({
|
||||||
@ -543,7 +544,13 @@ describe('Tools tests', () => {
|
|||||||
version: version,
|
version: version,
|
||||||
os: os
|
os: os
|
||||||
});
|
});
|
||||||
expect(await tools.addCastor(data)).toContain(uri);
|
if (os === 'win32' && version === '0.5.1') {
|
||||||
|
fs.writeFileSync('castor.php', '');
|
||||||
|
expect(await tools.addCastor(data)).toContain(uri);
|
||||||
|
fs.unlinkSync('castor.php');
|
||||||
|
} else {
|
||||||
|
expect(await tools.addCastor(data)).toContain(uri);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it.each`
|
it.each`
|
||||||
|
3
dist/index.js
vendored
3
dist/index.js
vendored
@ -841,6 +841,9 @@ async function addCastor(data) {
|
|||||||
data['tool'] = 'castor.' + data['os'].replace('win32', 'windows') + '-amd64';
|
data['tool'] = 'castor.' + data['os'].replace('win32', 'windows') + '-amd64';
|
||||||
data['url'] = await getUrl(data);
|
data['url'] = await getUrl(data);
|
||||||
data['tool'] = 'castor';
|
data['tool'] = 'castor';
|
||||||
|
data['version_parameter'] = fs_1.default.existsSync('castor.php')
|
||||||
|
? data['version_parameter']
|
||||||
|
: '';
|
||||||
return await addArchive(data);
|
return await addArchive(data);
|
||||||
}
|
}
|
||||||
exports.addCastor = addCastor;
|
exports.addCastor = addCastor;
|
||||||
|
@ -57,7 +57,7 @@ Function Get-ToolVersion() {
|
|||||||
Param (
|
Param (
|
||||||
[Parameter(Position = 0, Mandatory = $true)]
|
[Parameter(Position = 0, Mandatory = $true)]
|
||||||
$tool,
|
$tool,
|
||||||
[Parameter(Position = 1, Mandatory = $true)]
|
[Parameter(Position = 1, Mandatory = $false)]
|
||||||
$param
|
$param
|
||||||
)
|
)
|
||||||
$alp = "[a-zA-Z0-9\.]"
|
$alp = "[a-zA-Z0-9\.]"
|
||||||
@ -72,7 +72,9 @@ Function Get-ToolVersion() {
|
|||||||
Set-Variable -Name 'composer_version' -Value $composer_version -Scope Global
|
Set-Variable -Name 'composer_version' -Value $composer_version -Scope Global
|
||||||
return "$composer_version"
|
return "$composer_version"
|
||||||
}
|
}
|
||||||
return . $tool $param 2> $null | ForEach-Object { $_ -replace "composer $version_regex", '' } | Select-String -Pattern $version_regex | Select-Object -First 1 | ForEach-Object { $_.matches.Value }
|
if($null -ne $param) {
|
||||||
|
return . $tool $param 2> $null | ForEach-Object { $_ -replace "composer $version_regex", '' } | Select-String -Pattern $version_regex | Select-Object -First 1 | ForEach-Object { $_.matches.Value }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Helper function to configure tools.
|
# Helper function to configure tools.
|
||||||
@ -135,8 +137,7 @@ Function Add-Tool() {
|
|||||||
[Parameter(Position = 1, Mandatory = $true)]
|
[Parameter(Position = 1, Mandatory = $true)]
|
||||||
[ValidateNotNull()]
|
[ValidateNotNull()]
|
||||||
$tool,
|
$tool,
|
||||||
[Parameter(Position = 2, Mandatory = $true)]
|
[Parameter(Position = 2, Mandatory = $false)]
|
||||||
[ValidateNotNull()]
|
|
||||||
$ver_param
|
$ver_param
|
||||||
)
|
)
|
||||||
if (Test-Path $bin_dir\$tool) {
|
if (Test-Path $bin_dir\$tool) {
|
||||||
|
@ -19,7 +19,7 @@ get_tool_version() {
|
|||||||
composer_version="$(grep -Ea "const\sVERSION" "$tool_path_dir/composer" | grep -Eo "$version_regex")"
|
composer_version="$(grep -Ea "const\sVERSION" "$tool_path_dir/composer" | grep -Eo "$version_regex")"
|
||||||
fi
|
fi
|
||||||
echo "$composer_version" | sudo tee /tmp/composer_version
|
echo "$composer_version" | sudo tee /tmp/composer_version
|
||||||
else
|
elif [ -n "$param" ]; then
|
||||||
$tool "$param" 2>/dev/null | sed -Ee "s/[Cc]omposer(.)?$version_regex//g" | grep -Eo "$version_regex" | head -n 1
|
$tool "$param" 2>/dev/null | sed -Ee "s/[Cc]omposer(.)?$version_regex//g" | grep -Eo "$version_regex" | head -n 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -239,6 +239,9 @@ export async function addCastor(data: RS): Promise<string> {
|
|||||||
data['tool'] = 'castor.' + data['os'].replace('win32', 'windows') + '-amd64';
|
data['tool'] = 'castor.' + data['os'].replace('win32', 'windows') + '-amd64';
|
||||||
data['url'] = await getUrl(data);
|
data['url'] = await getUrl(data);
|
||||||
data['tool'] = 'castor';
|
data['tool'] = 'castor';
|
||||||
|
data['version_parameter'] = fs.existsSync('castor.php')
|
||||||
|
? data['version_parameter']
|
||||||
|
: '';
|
||||||
return await addArchive(data);
|
return await addArchive(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user