-
Notifications
You must be signed in to change notification settings - Fork 0
/
patch-zx.js
34 lines (30 loc) · 845 Bytes
/
patch-zx.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
const fs = require("node:fs");
const path = require("node:path");
const file = path.join(path.dirname(require.resolve("zx")), "core.js");
const bad_code
= `
try {
defaults.shell = which.sync('bash');
defaults.prefix = 'set -euo pipefail;';
defaults.quote = quote;
}
catch (err) {
if (process.platform == 'win32') {
defaults.shell = which.sync('powershell.exe');
defaults.quote = quotePowerShell;
}
}
`.trim();
const good_code
= `
if (process.platform === 'win32') {
defaults.shell = which.sync('powershell.exe');
defaults.quote = quotePowerShell;
} else {
defaults.shell = which.sync('bash');
defaults.prefix = 'set -euo pipefail;';
defaults.quote = quote;
}
`;
const core = String(fs.readFileSync(file));
fs.writeFileSync(file, core.replace(bad_code, good_code), { encoding: "utf8" });