From 3264f90427eb6da80e5956ab32991b3263941674 Mon Sep 17 00:00:00 2001 From: Ethan Mahlstedt Date: Fri, 9 May 2025 19:03:11 -0700 Subject: [PATCH 1/2] Fix PostInstall.js --- scripts/postinstall.js | 94 +++++++++++++++++++++++------------------- 1 file changed, 51 insertions(+), 43 deletions(-) diff --git a/scripts/postinstall.js b/scripts/postinstall.js index 4d8e415..20afff5 100644 --- a/scripts/postinstall.js +++ b/scripts/postinstall.js @@ -12,29 +12,33 @@ switch (platform) { // macOS specific code switch (arch) { case "x64": { - const scripts = fs.readdirSync( - path.join(__dirname, "darwin-x64", "postinstall") - ); - scripts.forEach((script) => { - if (script.endsWith(".js")) { - require( - path.join(__dirname, "darwin-x64", "postinstall", script) - )(); - } - }); + if(fs.existsSync(path.join(__dirname, "darwin-x64", "postinstall"))) { + const scripts = fs.readdirSync( + path.join(__dirname, "darwin-x64", "postinstall") + ); + scripts.forEach((script) => { + if (script.endsWith(".js")) { + require( + path.join(__dirname, "darwin-x64", "postinstall", script) + )(); + } + }); + }else return; break; } case "arm64": { - const scripts = fs.readdirSync( - path.join(__dirname, "darwin-arm64", "postinstall") - ); - scripts.forEach((script) => { - if (script.endsWith(".js")) { - require( - path.join(__dirname, "darwin-arm64", "postinstall", script) - )(); - } - }); + if(fs.existsSync(path.join(__dirname, "darwin-arm64", "postinstall"))) { + const scripts = fs.readdirSync( + path.join(__dirname, "darwin-arm64", "postinstall") + ); + scripts.forEach((script) => { + if (script.endsWith(".js")) { + require( + path.join(__dirname, "darwin-arm64", "postinstall", script) + )(); + } + }); + }else return; break; } default: @@ -42,32 +46,36 @@ switch (platform) { } break; case "linux": { - const scripts = fs.readdirSync( - path.join(__dirname, "linux", "postinstall") - ); - scripts.forEach((script) => { - if (script.endsWith(".js")) { - require(path.join(__dirname, "linux", "postinstall", script))(); - } else if (script.endsWith(".sh")) { - execSync( - `chmod +x ${path.join(__dirname, "linux", "postinstall", script)}` - ); - execSync(`${path.join(__dirname, "linux", "postinstall", script)}`); - } - }); + if(fs.existsSync(path.join(__dirname, "linux", "postinstall"))) { + const scripts = fs.readdirSync( + path.join(__dirname, "linux", "postinstall") + ); + scripts.forEach((script) => { + if (script.endsWith(".js")) { + require(path.join(__dirname, "linux", "postinstall", script))(); + } else if (script.endsWith(".sh")) { + execSync( + `chmod +x ${path.join(__dirname, "linux", "postinstall", script)}` + ); + execSync(`${path.join(__dirname, "linux", "postinstall", script)}`); + } + }); + }else return; break; } case "win32": { - const scripts = fs.readdirSync( - path.join(__dirname, "win32", "postinstall") - ); - scripts.forEach((script) => { - if (script.endsWith(".js")) { - require(path.join(__dirname, "win32", "postinstall", script))(); - } else if (script.endsWith(".bat")) { - execSync(`${path.join(__dirname, "win32", "postinstall", script)}`); - } - }); + if(fs.existsSync(path.join(__dirname, "win32", "postinstall"))) { + const scripts = fs.readdirSync( + path.join(__dirname, "win32", "postinstall") + ); + scripts.forEach((script) => { + if (script.endsWith(".js")) { + require(path.join(__dirname, "win32", "postinstall", script))(); + } else if (script.endsWith(".bat")) { + execSync(`${path.join(__dirname, "win32", "postinstall", script)}`); + } + }); + }else return; break; } default: From 06b651d67e2637d01455fb93abc45bacd5cd9fb4 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Sat, 10 May 2025 02:04:30 +0000 Subject: [PATCH 2/2] WF: Lint and Prettier: Fix postinstall.js --- scripts/postinstall.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/scripts/postinstall.js b/scripts/postinstall.js index 20afff5..82b8a57 100644 --- a/scripts/postinstall.js +++ b/scripts/postinstall.js @@ -12,7 +12,7 @@ switch (platform) { // macOS specific code switch (arch) { case "x64": { - if(fs.existsSync(path.join(__dirname, "darwin-x64", "postinstall"))) { + if (fs.existsSync(path.join(__dirname, "darwin-x64", "postinstall"))) { const scripts = fs.readdirSync( path.join(__dirname, "darwin-x64", "postinstall") ); @@ -23,11 +23,13 @@ switch (platform) { )(); } }); - }else return; + } else return; break; } case "arm64": { - if(fs.existsSync(path.join(__dirname, "darwin-arm64", "postinstall"))) { + if ( + fs.existsSync(path.join(__dirname, "darwin-arm64", "postinstall")) + ) { const scripts = fs.readdirSync( path.join(__dirname, "darwin-arm64", "postinstall") ); @@ -38,7 +40,7 @@ switch (platform) { )(); } }); - }else return; + } else return; break; } default: @@ -46,7 +48,7 @@ switch (platform) { } break; case "linux": { - if(fs.existsSync(path.join(__dirname, "linux", "postinstall"))) { + if (fs.existsSync(path.join(__dirname, "linux", "postinstall"))) { const scripts = fs.readdirSync( path.join(__dirname, "linux", "postinstall") ); @@ -60,11 +62,11 @@ switch (platform) { execSync(`${path.join(__dirname, "linux", "postinstall", script)}`); } }); - }else return; + } else return; break; } case "win32": { - if(fs.existsSync(path.join(__dirname, "win32", "postinstall"))) { + if (fs.existsSync(path.join(__dirname, "win32", "postinstall"))) { const scripts = fs.readdirSync( path.join(__dirname, "win32", "postinstall") ); @@ -75,7 +77,7 @@ switch (platform) { execSync(`${path.join(__dirname, "win32", "postinstall", script)}`); } }); - }else return; + } else return; break; } default: