From 535d3e8a40d99405b027fd29f63751bda8b02b8f Mon Sep 17 00:00:00 2001 From: Valentin Kiselev Date: Mon, 8 Aug 2022 11:20:32 +0300 Subject: [PATCH] fix: Move postinstall script to main lefthook package Signed-off-by: Valentin Kiselev --- .../npm/lefthook-darwin-arm64/package.json | 5 +---- packaging/npm/lefthook-darwin-x64/install.js | 21 ------------------- .../npm/lefthook-darwin-x64/package.json | 5 +---- packaging/npm/lefthook-linux-arm64/install.js | 21 ------------------- .../npm/lefthook-linux-arm64/package.json | 5 +---- packaging/npm/lefthook-linux-x64/install.js | 21 ------------------- packaging/npm/lefthook-linux-x64/package.json | 5 +---- .../npm/lefthook-windows-arm64/install.js | 21 ------------------- .../npm/lefthook-windows-arm64/package.json | 5 +---- packaging/npm/lefthook-windows-x64/install.js | 21 ------------------- .../npm/lefthook-windows-x64/package.json | 5 +---- packaging/npm/lefthook/package.json | 3 +++ .../install.js => lefthook/postinstall.js} | 6 ++---- 13 files changed, 11 insertions(+), 133 deletions(-) delete mode 100644 packaging/npm/lefthook-darwin-x64/install.js delete mode 100644 packaging/npm/lefthook-linux-arm64/install.js delete mode 100644 packaging/npm/lefthook-linux-x64/install.js delete mode 100644 packaging/npm/lefthook-windows-arm64/install.js delete mode 100644 packaging/npm/lefthook-windows-x64/install.js rename packaging/npm/{lefthook-darwin-arm64/install.js => lefthook/postinstall.js} (69%) diff --git a/packaging/npm/lefthook-darwin-arm64/package.json b/packaging/npm/lefthook-darwin-arm64/package.json index 13e23660..5f38bd54 100644 --- a/packaging/npm/lefthook-darwin-arm64/package.json +++ b/packaging/npm/lefthook-darwin-arm64/package.json @@ -15,8 +15,5 @@ ], "cpu": [ "arm64" - ], - "scripts": { - "install": "node install.js" - } + ] } diff --git a/packaging/npm/lefthook-darwin-x64/install.js b/packaging/npm/lefthook-darwin-x64/install.js deleted file mode 100644 index 5d5d170d..00000000 --- a/packaging/npm/lefthook-darwin-x64/install.js +++ /dev/null @@ -1,21 +0,0 @@ -const path = require("path") -const { spawnSync } = require("child_process") - -function install() { - if (process.env.CI) { - return - } - - const lefthook = path.join(__dirname, "bin", "lefthook") - - spawnSync(lefthook, ["install", "-f"], { - cwd: process.env.INIT_CWD || process.cwd(), - stdio: "inherit", - }) -} - -try { - install() -} catch(e) { - console.warn("'lefthook install' command failed. Try running it manually.\n" + e) -} diff --git a/packaging/npm/lefthook-darwin-x64/package.json b/packaging/npm/lefthook-darwin-x64/package.json index d5ed3110..34d6c34c 100644 --- a/packaging/npm/lefthook-darwin-x64/package.json +++ b/packaging/npm/lefthook-darwin-x64/package.json @@ -15,8 +15,5 @@ ], "cpu": [ "x64" - ], - "scripts": { - "install": "node install.js" - } + ] } diff --git a/packaging/npm/lefthook-linux-arm64/install.js b/packaging/npm/lefthook-linux-arm64/install.js deleted file mode 100644 index 5d5d170d..00000000 --- a/packaging/npm/lefthook-linux-arm64/install.js +++ /dev/null @@ -1,21 +0,0 @@ -const path = require("path") -const { spawnSync } = require("child_process") - -function install() { - if (process.env.CI) { - return - } - - const lefthook = path.join(__dirname, "bin", "lefthook") - - spawnSync(lefthook, ["install", "-f"], { - cwd: process.env.INIT_CWD || process.cwd(), - stdio: "inherit", - }) -} - -try { - install() -} catch(e) { - console.warn("'lefthook install' command failed. Try running it manually.\n" + e) -} diff --git a/packaging/npm/lefthook-linux-arm64/package.json b/packaging/npm/lefthook-linux-arm64/package.json index ecc00181..67332879 100644 --- a/packaging/npm/lefthook-linux-arm64/package.json +++ b/packaging/npm/lefthook-linux-arm64/package.json @@ -15,8 +15,5 @@ ], "cpu": [ "arm64" - ], - "scripts": { - "install": "node install.js" - } + ] } diff --git a/packaging/npm/lefthook-linux-x64/install.js b/packaging/npm/lefthook-linux-x64/install.js deleted file mode 100644 index 5d5d170d..00000000 --- a/packaging/npm/lefthook-linux-x64/install.js +++ /dev/null @@ -1,21 +0,0 @@ -const path = require("path") -const { spawnSync } = require("child_process") - -function install() { - if (process.env.CI) { - return - } - - const lefthook = path.join(__dirname, "bin", "lefthook") - - spawnSync(lefthook, ["install", "-f"], { - cwd: process.env.INIT_CWD || process.cwd(), - stdio: "inherit", - }) -} - -try { - install() -} catch(e) { - console.warn("'lefthook install' command failed. Try running it manually.\n" + e) -} diff --git a/packaging/npm/lefthook-linux-x64/package.json b/packaging/npm/lefthook-linux-x64/package.json index 6a4a1784..bf7b7537 100644 --- a/packaging/npm/lefthook-linux-x64/package.json +++ b/packaging/npm/lefthook-linux-x64/package.json @@ -15,8 +15,5 @@ ], "cpu": [ "x64" - ], - "scripts": { - "install": "node install.js" - } + ] } diff --git a/packaging/npm/lefthook-windows-arm64/install.js b/packaging/npm/lefthook-windows-arm64/install.js deleted file mode 100644 index fed73f41..00000000 --- a/packaging/npm/lefthook-windows-arm64/install.js +++ /dev/null @@ -1,21 +0,0 @@ -const path = require("path") -const { spawnSync } = require("child_process") - -function install() { - if (process.env.CI) { - return - } - - const lefthook = path.join(__dirname, "bin", "lefthook.exe") - - spawnSync(lefthook, ["install", "-f"], { - cwd: process.env.INIT_CWD || process.cwd(), - stdio: "inherit", - }) -} - -try { - install() -} catch(e) { - console.warn("'lefthook install' command failed. Try running it manually.\n" + e) -} diff --git a/packaging/npm/lefthook-windows-arm64/package.json b/packaging/npm/lefthook-windows-arm64/package.json index 2c1f32df..d88c8c4d 100644 --- a/packaging/npm/lefthook-windows-arm64/package.json +++ b/packaging/npm/lefthook-windows-arm64/package.json @@ -15,8 +15,5 @@ ], "cpu": [ "arm64" - ], - "scripts": { - "install": "node install.js" - } + ] } diff --git a/packaging/npm/lefthook-windows-x64/install.js b/packaging/npm/lefthook-windows-x64/install.js deleted file mode 100644 index fed73f41..00000000 --- a/packaging/npm/lefthook-windows-x64/install.js +++ /dev/null @@ -1,21 +0,0 @@ -const path = require("path") -const { spawnSync } = require("child_process") - -function install() { - if (process.env.CI) { - return - } - - const lefthook = path.join(__dirname, "bin", "lefthook.exe") - - spawnSync(lefthook, ["install", "-f"], { - cwd: process.env.INIT_CWD || process.cwd(), - stdio: "inherit", - }) -} - -try { - install() -} catch(e) { - console.warn("'lefthook install' command failed. Try running it manually.\n" + e) -} diff --git a/packaging/npm/lefthook-windows-x64/package.json b/packaging/npm/lefthook-windows-x64/package.json index 44221566..8c201d76 100644 --- a/packaging/npm/lefthook-windows-x64/package.json +++ b/packaging/npm/lefthook-windows-x64/package.json @@ -15,8 +15,5 @@ ], "cpu": [ "x64" - ], - "scripts": { - "install": "node install.js" - } + ] } diff --git a/packaging/npm/lefthook/package.json b/packaging/npm/lefthook/package.json index a1d994a3..b27742f6 100644 --- a/packaging/npm/lefthook/package.json +++ b/packaging/npm/lefthook/package.json @@ -26,5 +26,8 @@ "lefthook-linux-x64": "1.0.5", "lefthook-windows-arm64": "1.0.5", "lefthook-windows-x64": "1.0.5" + }, + "scripts": { + "postinstall": "node postinstall.js" } } diff --git a/packaging/npm/lefthook-darwin-arm64/install.js b/packaging/npm/lefthook/postinstall.js similarity index 69% rename from packaging/npm/lefthook-darwin-arm64/install.js rename to packaging/npm/lefthook/postinstall.js index 5d5d170d..200e7561 100644 --- a/packaging/npm/lefthook-darwin-arm64/install.js +++ b/packaging/npm/lefthook/postinstall.js @@ -1,14 +1,12 @@ -const path = require("path") const { spawnSync } = require("child_process") +const { getExePath } = require("./get-exe") function install() { if (process.env.CI) { return } - const lefthook = path.join(__dirname, "bin", "lefthook") - - spawnSync(lefthook, ["install", "-f"], { + spawnSync(getExePath(), ["install", "-f"], { cwd: process.env.INIT_CWD || process.cwd(), stdio: "inherit", })