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.
Files changed (3) hide show
  1. package/get-exe.js +20 -0
  2. package/package.json +13 -11
  3. package/postinstall.js +21 -0
package/get-exe.js ADDED
@@ -0,0 +1,20 @@
1
+ const path = require("path");
2
+
3
+ function getExePath() {
4
+ // Detect OS
5
+ // https://nodejs.org/api/process.html#process_process_platform
6
+ let os = process.platform;
7
+ let extension = "";
8
+ if (["win32", "cygwin"].includes(process.platform)) {
9
+ os = "windows";
10
+ extension = ".exe";
11
+ }
12
+
13
+ // Detect architecture
14
+ // https://nodejs.org/api/process.html#process_process_arch
15
+ let arch = process.arch;
16
+
17
+ return require.resolve(`lefthook-${os}-${arch}/bin/lefthook${extension}`);
18
+ }
19
+
20
+ exports.getExePath = getExePath;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lefthook",
3
- "version": "1.10.6",
3
+ "version": "1.10.7",
4
4
  "description": "Simple git hooks manager",
5
5
  "repository": {
6
6
  "type": "git",
@@ -8,6 +8,8 @@
8
8
  },
9
9
  "main": "bin/index.js",
10
10
  "files": [
11
+ "postinstall.js",
12
+ "get-exe.js",
11
13
  "schema.json"
12
14
  ],
13
15
  "bin": {
@@ -26,16 +28,16 @@
26
28
  },
27
29
  "homepage": "https://github.com/evilmartians/lefthook#readme",
28
30
  "optionalDependencies": {
29
- "lefthook-darwin-arm64": "1.10.6",
30
- "lefthook-darwin-x64": "1.10.6",
31
- "lefthook-linux-arm64": "1.10.6",
32
- "lefthook-linux-x64": "1.10.6",
33
- "lefthook-freebsd-arm64": "1.10.6",
34
- "lefthook-freebsd-x64": "1.10.6",
35
- "lefthook-openbsd-arm64": "1.10.6",
36
- "lefthook-openbsd-x64": "1.10.6",
37
- "lefthook-windows-arm64": "1.10.6",
38
- "lefthook-windows-x64": "1.10.6"
31
+ "lefthook-darwin-arm64": "1.10.7",
32
+ "lefthook-darwin-x64": "1.10.7",
33
+ "lefthook-linux-arm64": "1.10.7",
34
+ "lefthook-linux-x64": "1.10.7",
35
+ "lefthook-freebsd-arm64": "1.10.7",
36
+ "lefthook-freebsd-x64": "1.10.7",
37
+ "lefthook-openbsd-arm64": "1.10.7",
38
+ "lefthook-openbsd-x64": "1.10.7",
39
+ "lefthook-windows-arm64": "1.10.7",
40
+ "lefthook-windows-x64": "1.10.7"
39
41
  },
40
42
  "scripts": {
41
43
  "postinstall": "node postinstall.js"
package/postinstall.js ADDED
@@ -0,0 +1,21 @@
1
+ const { spawnSync } = require("child_process");
2
+ const { getExePath } = require("./get-exe");
3
+
4
+ function install() {
5
+ if (process.env.CI) {
6
+ return;
7
+ }
8
+
9
+ spawnSync(getExePath(), ["install", "-f"], {
10
+ cwd: process.env.INIT_CWD || process.cwd(),
11
+ stdio: "inherit",
12
+ });
13
+ }
14
+
15
+ try {
16
+ install();
17
+ } catch (e) {
18
+ console.warn(
19
+ "'lefthook install' command failed. Try running it manually.\n" + e,
20
+ );
21
+ }