@evilmartians/lefthook 1.10.6 → 1.10.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/get-exe.js +33 -0
- package/package.json +3 -1
- package/postinstall.js +10 -0
package/get-exe.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const path = require("path")
|
|
2
|
+
|
|
3
|
+
function getExePath() {
|
|
4
|
+
// Detect OS
|
|
5
|
+
// https://nodejs.org/api/process.html#process_process_platform
|
|
6
|
+
let goOS = process.platform;
|
|
7
|
+
let extension = '';
|
|
8
|
+
if (['win32', 'cygwin'].includes(process.platform)) {
|
|
9
|
+
goOS = 'windows';
|
|
10
|
+
extension = '.exe';
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// Detect architecture
|
|
14
|
+
// https://nodejs.org/api/process.html#process_process_arch
|
|
15
|
+
let goArch = process.arch;
|
|
16
|
+
let suffix = '';
|
|
17
|
+
switch (process.arch) {
|
|
18
|
+
case 'x32':
|
|
19
|
+
case 'ia32': {
|
|
20
|
+
goArch = '386';
|
|
21
|
+
break;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const dir = path.join(__dirname, 'bin');
|
|
26
|
+
const executable = path.join(
|
|
27
|
+
dir,
|
|
28
|
+
`lefthook-${goOS}-${goArch}`,
|
|
29
|
+
`lefthook${extension}`
|
|
30
|
+
);
|
|
31
|
+
return executable;
|
|
32
|
+
}
|
|
33
|
+
exports.getExePath = getExePath;
|
package/package.json
CHANGED
package/postinstall.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
if (!process.env.CI) {
|
|
2
|
+
const { spawnSync } = require('child_process');
|
|
3
|
+
const { getExePath } = require('./get-exe');
|
|
4
|
+
|
|
5
|
+
// run install
|
|
6
|
+
spawnSync(getExePath(), ['install', '-f'], {
|
|
7
|
+
cwd: process.env.INIT_CWD || process.cwd(),
|
|
8
|
+
stdio: 'inherit',
|
|
9
|
+
});
|
|
10
|
+
}
|