test: async test -> sync
This commit is contained in:
parent
0cf6bc4d0e
commit
864dd31b7b
@ -52,7 +52,8 @@ describe('Utils tests', () => {
|
|||||||
expect(await utils.parseVersion('4.x')).toBe(undefined);
|
expect(await utils.parseVersion('4.x')).toBe(undefined);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('checking resolveVersionInput', async () => {
|
it('checking resolveVersionInput', () => {
|
||||||
|
// composer.json
|
||||||
expect(utils.parsePhpVersionFile('{"require": {"php": "^8.1"}}')).toBe(
|
expect(utils.parsePhpVersionFile('{"require": {"php": "^8.1"}}')).toBe(
|
||||||
'8.1'
|
'8.1'
|
||||||
);
|
);
|
||||||
@ -68,6 +69,10 @@ describe('Utils tests', () => {
|
|||||||
expect(utils.parsePhpVersionFile('{"require": {"php": "^8.1|^8.0"}}')).toBe(
|
expect(utils.parsePhpVersionFile('{"require": {"php": "^8.1|^8.0"}}')).toBe(
|
||||||
'8.1'
|
'8.1'
|
||||||
);
|
);
|
||||||
|
// asdf: .tool-versions
|
||||||
|
expect(utils.parsePhpVersionFile('php 8.1')).toBe('8.1');
|
||||||
|
// phpenv: .php-version
|
||||||
|
expect(utils.parsePhpVersionFile('8.1.1')).toBe('8.1');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('checking parseIniFile', async () => {
|
it('checking parseIniFile', async () => {
|
||||||
|
|||||||
6
dist/index.js
vendored
6
dist/index.js
vendored
@ -1070,10 +1070,8 @@ async function resolveVersionInput() {
|
|||||||
}
|
}
|
||||||
exports.resolveVersionInput = resolveVersionInput;
|
exports.resolveVersionInput = resolveVersionInput;
|
||||||
function parsePhpVersionFile(contents) {
|
function parsePhpVersionFile(contents) {
|
||||||
const json = JSON.parse(contents);
|
const match = contents.match(/("php:")?.*?(\d+(\.\d+))/);
|
||||||
const version = json.config?.platform?.php ?? json.require?.php;
|
return match ? match[2] : '';
|
||||||
const match = version.match(/(\d+(\.\d+))/);
|
|
||||||
return match ? match[1] : '';
|
|
||||||
}
|
}
|
||||||
exports.parsePhpVersionFile = parsePhpVersionFile;
|
exports.parsePhpVersionFile = parsePhpVersionFile;
|
||||||
async function getManifestURL() {
|
async function getManifestURL() {
|
||||||
|
|||||||
@ -76,10 +76,8 @@ export async function resolveVersionInput(): Promise<string> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function parsePhpVersionFile(contents: string): string {
|
export function parsePhpVersionFile(contents: string): string {
|
||||||
const json = JSON.parse(contents);
|
const match = contents.match(/("php:")?.*?(\d+(\.\d+))/);
|
||||||
const version = json.config?.platform?.php ?? json.require?.php;
|
return match ? match[2] : '';
|
||||||
const match = version.match(/(\d+(\.\d+))/);
|
|
||||||
return match ? match[1] : '';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Function to get manifest URL
|
/** Function to get manifest URL
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user