|
1 | | -import { exec } from "node:child_process"; |
| 1 | +import { execSync } from "node:child_process"; |
2 | 2 | import { Shescape } from "shescape"; |
3 | 3 |
|
4 | 4 | const options = { shell: "powershell" }; |
5 | 5 | const shescape = new Shescape({ shell: "powershell" }); |
6 | 6 |
|
7 | | -exec(`gh ${shescape.escape("--help")}`, options, (error) => { |
8 | | - if (error) { |
9 | | - console.log("gh --help : error"); |
10 | | - } else { |
11 | | - console.log("gh --help : no error"); |
12 | | - } |
13 | | -}); |
14 | | -exec(`gh ${shescape.escape("`--help")}`, options, (error) => { |
15 | | - if (error) { |
16 | | - console.log("gh `--help : error"); |
17 | | - } else { |
18 | | - console.log("gh `--help : no error"); |
19 | | - } |
20 | | -}); |
21 | | -exec(`gh ${shescape.escape("``--help")}`, options, options, (error) => { |
22 | | - if (error) { |
23 | | - console.log("gh ``--help : error"); |
24 | | - } else { |
25 | | - console.log("gh ``--help : no error"); |
26 | | - } |
27 | | -}); |
| 7 | +try { |
| 8 | + execSync(`gh ${shescape.escape("--help")}`, options); |
| 9 | + console.log("gh --help : no error"); |
| 10 | +} catch { |
| 11 | + console.log("gh --help : error"); |
| 12 | +} |
| 13 | +try { |
| 14 | + execSync(`gh ${shescape.escape("`--help")}`, options); |
| 15 | + console.log("gh `--help : no error"); |
| 16 | +} catch { |
| 17 | + console.log("gh `--help : error"); |
| 18 | +} |
| 19 | +try { |
| 20 | + execSync(`gh ${shescape.escape("``--help")}`, options, options); |
| 21 | + console.log("gh ``--help : no error"); |
| 22 | +} catch { |
| 23 | + console.log("gh ``--help : error"); |
| 24 | +} |
28 | 25 |
|
29 | | -exec(`gh ${shescape.quote("--help")}`, options, (error) => { |
30 | | - if (error) { |
31 | | - console.log("gh '--help': error"); |
32 | | - } else { |
33 | | - console.log("gh '--help': no error"); |
34 | | - } |
35 | | -}); |
36 | | -exec(`gh ${shescape.quote("`--help")}`, options, (error) => { |
37 | | - if (error) { |
38 | | - console.log("gh '`--help': error"); |
39 | | - } else { |
40 | | - console.log("gh '`--help': no error"); |
41 | | - } |
42 | | -}); |
43 | | -exec(`gh ${shescape.quote("``--help")}`, options, (error) => { |
44 | | - if (error) { |
45 | | - console.log("gh '``--help': error"); |
46 | | - } else { |
47 | | - console.log("gh '``--help': no error"); |
48 | | - } |
49 | | -}); |
| 26 | +try { |
| 27 | + execSync(`gh ${shescape.quote("--help")}`, options); |
| 28 | + console.log("gh '--help': no error"); |
| 29 | +} catch { |
| 30 | + console.log("gh '--help': error"); |
| 31 | +} |
| 32 | +try { |
| 33 | + execSync(`gh ${shescape.quote("`--help")}`, options); |
| 34 | + console.log("gh '`--help': no error"); |
| 35 | +} catch { |
| 36 | + console.log("gh '`--help': error"); |
| 37 | +} |
| 38 | +try { |
| 39 | + execSync(`gh ${shescape.quote("``--help")}`, options); |
| 40 | + console.log("gh '``--help': no error"); |
| 41 | +} catch { |
| 42 | + console.log("gh '``--help': error"); |
| 43 | +} |
0 commit comments