Skip to content

Commit bb13a49

Browse files
committed
Support any method for PowerShell
1 parent cee79a5 commit bb13a49

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

src/targets/powershell/common.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,19 @@ export const generatePowershellConvert = (command: PowershellCommand) => {
1616
allHeaders,
1717
}) => {
1818
const { push, join } = new CodeBuilder();
19-
const methods = ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'HEAD', 'OPTIONS'];
20-
21-
if (!methods.includes(method.toUpperCase())) {
22-
return 'Method not supported';
23-
}
19+
const methods = [
20+
'DEFAULT',
21+
'DELETE',
22+
'GET',
23+
'HEAD',
24+
'MERGE',
25+
'OPTIONS',
26+
'PATCH',
27+
'POST',
28+
'PUT',
29+
'TRACE'
30+
];
31+
const methodArg = methods.includes(method.toUpperCase()) ? '-Method' : '-CustomMethod';
2432

2533
const commandOptions = [];
2634

@@ -62,7 +70,7 @@ export const generatePowershellConvert = (command: PowershellCommand) => {
6270
commandOptions.push(`-Body '${postData.text}'`);
6371
}
6472

65-
push(`$response = ${command} -Uri '${fullUrl}' -Method ${method} ${commandOptions.join(' ')}`);
73+
push(`$response = ${command} -Uri '${fullUrl}' ${methodArg} ${method} ${commandOptions.join(' ')}`);
6674
return join();
6775
};
6876
return convert;

0 commit comments

Comments
 (0)