(raw: RawRedirection)
| 960 | /** Map raw redirection to ParsedRedirection */ |
| 961 | // exported for testing |
| 962 | export function transformRedirection(raw: RawRedirection): ParsedRedirection { |
| 963 | if (raw.type === 'MergingRedirectionAst') { |
| 964 | return { operator: '2>&1', target: '', isMerging: true } |
| 965 | } |
| 966 | |
| 967 | const append = raw.append ?? false |
| 968 | const fromStream = raw.fromStream ?? 'Output' |
| 969 | |
| 970 | let operator: ParsedRedirection['operator'] |
| 971 | if (append) { |
| 972 | switch (fromStream) { |
| 973 | case 'Error': |
| 974 | operator = '2>>' |
| 975 | break |
| 976 | case 'All': |
| 977 | operator = '*>>' |
| 978 | break |
| 979 | default: |
| 980 | operator = '>>' |
| 981 | break |
| 982 | } |
| 983 | } else { |
| 984 | switch (fromStream) { |
| 985 | case 'Error': |
| 986 | operator = '2>' |
| 987 | break |
| 988 | case 'All': |
| 989 | operator = '*>' |
| 990 | break |
| 991 | default: |
| 992 | operator = '>' |
| 993 | break |
| 994 | } |
| 995 | } |
| 996 | |
| 997 | return { operator, target: raw.locationText ?? '', isMerging: false } |
| 998 | } |
| 999 | |
| 1000 | /** Transform a raw statement into ParsedStatement */ |
| 1001 | // exported for testing |
no outgoing calls
no test coverage detected