-
Notifications
You must be signed in to change notification settings - Fork 321
Expand file tree
/
Copy pathpostinstall.js
More file actions
28 lines (24 loc) · 762 Bytes
/
postinstall.js
File metadata and controls
28 lines (24 loc) · 762 Bytes
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
const os = require("os");
const path = require("path");
const fs = require("fs");
const pkgName = require("./package.json").name;
require("./download")((err) => {
// Fix default executable path on Windows Git Bash
if (!err && process.env.MSYSTEM && os.release().includes("10")) {
const exeFile = path.resolve(
process.env.APPDATA,
path.join("npm", pkgName)
);
if (fs.existsSync(exeFile)) {
const parsedContent = fs
.readFileSync(exeFile)
.toString()
.replace(
`"$basedir/node_modules/${pkgName}/bin/${pkgName}"`,
`"winpty" "$basedir/node_modules/${pkgName}/bin/${pkgName}.exe"`
);
fs.writeFileSync(exeFile, parsedContent);
}
}
process.exit(err ? 1 : 0);
});