Fix reading unquoted versions

This commit is contained in:
Shivam Mathur 2019-12-14 10:13:01 +05:30
parent 8f8207a1ca
commit 2b027bd9bc
No known key found for this signature in database
GPG Key ID: 3E13E4C8591ACC2A
5 changed files with 15 additions and 6 deletions

View File

@ -26,7 +26,7 @@ jobs:
fail-fast: false
matrix:
operating-system: [ubuntu-latest, ubuntu-16.04, macOS-latest]
php-versions: ['8.0']
php-versions: [8.0]
steps:
- name: Checkout
uses: actions/checkout@v1

View File

@ -24,7 +24,7 @@ jobs:
fail-fast: false
matrix:
operating-system: [ubuntu-latest, windows-latest, macOS-latest]
php-versions: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4']
php-versions: [5.6, 7.0, 7.1, 7.2, 7.3, 7.4]
steps:
- name: Checkout
uses: actions/checkout@v1

View File

@ -31,7 +31,8 @@ jest.mock('../src/install', () => ({
run: jest.fn().mockImplementation(
async (): Promise<string> => {
const os_version: string = process.env['RUNNER_OS'] || '';
const version: string = process.env['php-version'] || '';
let version: string = process.env['php-version'] || '';
version = version.length > 1 ? version : version + '.0';
let script = '';
switch (os_version) {
case 'darwin':
@ -85,10 +86,16 @@ function setEnv(
describe('Install', () => {
it('Test install on windows', async () => {
setEnv('7.3', 'win32', '', '', '', '');
setEnv('7.0', 'win32', '', '', '', '');
// @ts-ignore
let script: string = await install.run();
expect(script).toContain('initial script');
expect(script).toContain('pwsh script.ps1 -version 7.0 -dir ' + __dirname);
setEnv('7.3', 'win32', '', '', '', '');
// @ts-ignore
script = await install.run();
expect(script).toContain('initial script');
expect(script).toContain('pwsh script.ps1 -version 7.3 -dir ' + __dirname);
setEnv('7.3', 'win32', 'a, b', 'a=b', 'x', '');

3
dist/index.js vendored
View File

@ -1831,7 +1831,8 @@ function run() {
return __awaiter(this, void 0, void 0, function* () {
try {
const os_version = process.platform;
const version = yield utils.getInput('php-version', true);
let version = yield utils.getInput('php-version', true);
version = version.length > 1 ? version : version + '.0';
// check the os version and run the respective script
let script_path = '';
switch (os_version) {

View File

@ -46,7 +46,8 @@ export async function build(
export async function run(): Promise<void> {
try {
const os_version: string = process.platform;
const version: string = await utils.getInput('php-version', true);
let version: string = await utils.getInput('php-version', true);
version = version.length > 1 ? version : version + '.0';
// check the os version and run the respective script
let script_path = '';
switch (os_version) {