Skip to content

Commit

Permalink
Add support for tools: none
Browse files Browse the repository at this point in the history
  • Loading branch information
shivammathur committed Apr 21, 2021
1 parent 254ecd5 commit 8cfcbb0
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
10 changes: 10 additions & 0 deletions __tests__/tools.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -583,5 +583,15 @@ describe('Tools tests', () => {
expect(script).toContain(
'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-snapshot.phar,https://getcomposer.org/composer.phar composer snapshot'
);

script = await tools.addTools('none', '7.4', 'linux');
expect(script).toStrictEqual('');

script = await tools.addTools('none, phpunit', '7.4', 'linux');
expect(script).toStrictEqual(
'\nstep_log "Setup Tools"' +
'\nadd_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-stable.phar,https://getcomposer.org/composer-stable.phar composer latest\n' +
'\nadd_tool https://phar.phpunit.de/phpunit.phar phpunit "--version"'
);
});
});
10 changes: 9 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2452,7 +2452,13 @@ exports.addPackage = addPackage;
* @param os_version
*/
async function addTools(tools_csv, php_version, os_version) {
let script = '\n' + (await utils.stepLog('Setup Tools', os_version));
let script = '\n';
if (tools_csv === 'none') {
return '';
}
else {
script += await utils.stepLog('Setup Tools', os_version);
}
const tools_list = await addComposer(await utils.CSVArray(tools_csv));
await utils.asyncForEach(tools_list, async function (release) {
const tool_data = await parseTool(release);
Expand Down Expand Up @@ -2575,6 +2581,8 @@ async function addTools(tools_csv, php_version, os_version) {
url = github + (await getWpCliUrl(version));
script += await addArchive('wp-cli', url, os_version, '"--version"');
break;
case /^none$/.test(tool):
break;
case /^[\w.-]+\/[\w.-]+$/.test(tool):
script += await addPackage(tool.split('/')[1], release.split('/')[1].replace(/\s+/, ''), tool.split('/')[0] + '/', os_version);
break;
Expand Down
9 changes: 8 additions & 1 deletion src/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,12 @@ export async function addTools(
php_version: string,
os_version: string
): Promise<string> {
let script = '\n' + (await utils.stepLog('Setup Tools', os_version));
let script = '\n';
if (tools_csv === 'none') {
return '';
} else {
script += await utils.stepLog('Setup Tools', os_version);
}
const tools_list = await addComposer(await utils.CSVArray(tools_csv));
await utils.asyncForEach(tools_list, async function (release: string) {
const tool_data: {name: string; version: string} = await parseTool(release);
Expand Down Expand Up @@ -513,6 +518,8 @@ export async function addTools(
url = github + (await getWpCliUrl(version));
script += await addArchive('wp-cli', url, os_version, '"--version"');
break;
case /^none$/.test(tool):
break;
case /^[\w.-]+\/[\w.-]+$/.test(tool):
script += await addPackage(
tool.split('/')[1],
Expand Down

0 comments on commit 8cfcbb0

Please sign in to comment.