Skip to content

Commit

Permalink
refactor: changes
Browse files Browse the repository at this point in the history
  • Loading branch information
topliceanurazvan committed Jan 5, 2024
1 parent ec6930e commit edec3f6
Showing 1 changed file with 2 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,7 @@ import {prettifyArguments} from '@utils/prettifyArguments';
import {ArgumentsWrapper} from './Arguments.styled';

const formatArgsArray = (args: string[]) => {
return args.map(arg => {
const trimmedArg = arg.replace(/\s+|(?<=[^'])['"](?=[^'])/g, match => {
if (match.trim() === '') {
return ' '; // Replaces multiple spaces with a single space
}
return `\\${match}`; // Escapes quotes
});

return arg.includes(' ') ? `"${trimmedArg}"` : trimmedArg;
});
return args.map(arg => (arg.includes(' ') ? `"${arg}"` : arg));
};

type ArgumentsFormValues = {
Expand All @@ -61,7 +52,6 @@ const Arguments: React.FC<ArgumentsProps> = ({readOnly}) => {
const initialArgs = useMemo(() => formatArgsArray(entityArgs)?.join('\n') || '', [entityArgs]);

const currentArgs = Form.useWatch('args', form) || '';
const currentArgsInline = currentArgs.replace(/\s+/g, ' ').trim();

const isPrettified = useMemo(() => currentArgs === prettifyArguments(currentArgs), [currentArgs]);

Expand Down Expand Up @@ -115,7 +105,7 @@ const Arguments: React.FC<ArgumentsProps> = ({readOnly}) => {
onCancel={onCancel}
>
<ArgumentsWrapper>
<CopyCommand command={currentArgsInline} isBordered additionalPrefix="executor-binary" />
<CopyCommand command={currentArgs} isBordered additionalPrefix="executor-binary" />
<FullWidthSpace size={16} direction="vertical">
<Text className="regular middle" color={Colors.slate400}>
Arguments passed to the executor (concat and passed directly to the executor)
Expand Down

0 comments on commit edec3f6

Please sign in to comment.