Skip to content

Commit

Permalink
fix(designer): Update token code for powershell custom code (#4960)
Browse files Browse the repository at this point in the history
* remove outputs if not included

* boilerplate code update

* add a space
  • Loading branch information
Eric-B-Wu committed Jun 14, 2024
1 parent 7ded280 commit 47b7c07
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
15 changes: 11 additions & 4 deletions libs/designer-ui/src/lib/code/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export function buildInlineCodeTextFromToken(inputToken: Token, language: string
return formatForJavascript(property, actionName, source);
}
case constants.PARAMETER.EDITOR_OPTIONS.LANGUAGE.POWERSHELL: {
return formatForPowershell(segmentedProperty, actionName, source);
return formatForPowershell(property, actionName, source);
}
case constants.PARAMETER.EDITOR_OPTIONS.LANGUAGE.CSHARP: {
return formatForCSharp(segmentedProperty, actionName, source ? capitalizeFirstLetter(source) : source);
Expand Down Expand Up @@ -116,9 +116,16 @@ function formatForJavascript(property: string, actionName?: string, source?: str
}

function formatForPowershell(property: string, actionName?: string, source?: string): string {
const result = `(get-WorkflowActionOutputs -actionName ${actionName ?? capitalizeFirstLetter(OperationCategory.Trigger)})${
source ? `["${source}"]` : ''
}${property}`;
const type = actionName ? `(Get-ActionOutput -ActionName "${actionName}")` : '(Get-TriggerOutput)';
let result = type;
if (source === 'outputs') {
result = `${result}.${source}`;
} else {
result = `${result}.outputs.${source}`;
}
if (property) {
result = `${result}.${property}`;
}

return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const getFileExtensionName = (language: EditorLanguage): string => {

export const getAppFileForFileExtension = (fileExtension: string): string => {
if (fileExtension === '.ps1') {
return "# This file enables modules to be automatically managed by the Functions service.\r\n# See https://aka.ms/functionsmanageddependency for additional information.\r\n#\r\n@{\r\n # For latest supported version, go to 'https://www.powershellgallery.com/packages/Az'. Uncomment the next line and replace the MAJOR_VERSION, e.g., 'Az' = '5.*'\r\n 'Az' = '10.*'\r\n}";
return "# This file enables modules to be automatically managed by the Functions service.\r\n# See https://aka.ms/functionsmanageddependency for additional information.\r\n#\r\n@{\r\n # For latest supported version, go to 'https://www.powershellgallery.com/packages/Az'. Uncomment the next line and replace the MAJOR_VERSION, e.g., 'Az' = '5.*'\r\n # 'Az' = '10.*'\r\n}";
}
return '';
};
Expand Down

0 comments on commit 47b7c07

Please sign in to comment.