From fc19e899d9175903346adc642670c9bcf26dc7d0 Mon Sep 17 00:00:00 2001
From: Andres Correa Casablanca <castarco@coderspirit.xyz>
Date: Sat, 19 Nov 2022 19:39:06 +0100
Subject: [PATCH] fix: apply chmod at pkg creation time

apply chmod at package creation time instead of doing it when running
the postinstall hook.

Signed-off-by: Andres Correa Casablanca <castarco@coderspirit.xyz>
---
 npm/rome/scripts/generate-packages.mjs |  1 +
 npm/rome/scripts/postinstall.js        | 11 -----------
 2 files changed, 1 insertion(+), 11 deletions(-)

diff --git a/npm/rome/scripts/generate-packages.mjs b/npm/rome/scripts/generate-packages.mjs
index e231ffb5ef0..0fea1d0dbb8 100644
--- a/npm/rome/scripts/generate-packages.mjs
+++ b/npm/rome/scripts/generate-packages.mjs
@@ -44,6 +44,7 @@ function generateNativePackage(platform, arch) {
 
 	console.log(`Copy binary ${binaryTarget}`);
 	fs.copyFileSync(binarySource, binaryTarget);
+	fs.chmodSync(binaryTarget, 0o755);
 }
 
 function updateWasmPackage(target) {
diff --git a/npm/rome/scripts/postinstall.js b/npm/rome/scripts/postinstall.js
index 392c13c4b65..8cff68be341 100644
--- a/npm/rome/scripts/postinstall.js
+++ b/npm/rome/scripts/postinstall.js
@@ -25,17 +25,6 @@ if (binName) {
 			`The Rome CLI postinstall script failed to resolve the binary file "${binName}". Running Rome from the npm package will probably not work correctly.`,
 		);
 	}
-
-	if (binPath) {
-		try {
-			require("fs").chmodSync(binPath, 0o755);
-		} catch {
-			console.warn(
-				"The Rome CLI postinstall script failed to set execution permissions to the native binary. " +
-					"Running Rome from the npm package will probably not work correctly.",
-			);
-		}
-	}
 } else {
 	console.warn(
 		"The Rome CLI package doesn't ship with prebuilt binaries for your platform yet. " +