Normalize argument that can be specific as either one or two arguments. In some cases these arguments are simply joined together. For example [`-o` `foo`] becomes `-ofoo` and [`-L` `bar`] becomes `-Lbar`. In other cases they are joined by an equals sign. For example ['--js-library`, `foo.j
(args)
| 801 | |
| 802 | |
| 803 | def normalize_args(args): |
| 804 | """Normalize argument that can be specific as either one or two arguments. |
| 805 | |
| 806 | In some cases these arguments are simply joined together. For example |
| 807 | [`-o` `foo`] becomes `-ofoo` and [`-L` `bar`] becomes `-Lbar`. |
| 808 | |
| 809 | In other cases they are joined by an equals sign. For example ['--js-library`, `foo.js`] |
| 810 | becomes `--js-library=foo.js`. |
| 811 | """ |
| 812 | equals_args = {'--js-library'} |
| 813 | join_args = {'-l', '-L', '-I', '-z', '-o', '-x', '-u'} | equals_args |
| 814 | for i in range(len(args)): |
| 815 | if args[i] in join_args: |
| 816 | if args[i] in equals_args: |
| 817 | args[i] += '=' |
| 818 | if len(args) <= i + 1: |
| 819 | exit_with_error(f"option '{args[i]}' requires an argument") |
| 820 | args[i] += args[i + 1] |
| 821 | args[i + 1] = '' |
| 822 | |
| 823 | return [a for a in args if a] |
| 824 | |
| 825 | |
| 826 | @ToolchainProfiler.profile() |
no test coverage detected