From b4741982677a3cbecd29c45aa049e9bfd2e36372 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Vanegas=20Jim=C3=A9nez?= <142350+angeldeejay@users.noreply.github.com> Date: Tue, 5 May 2026 15:05:46 -0500 Subject: [PATCH] fix: skip postinstall git clean when not in a git repository (#4139) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## What does this PR accomplish? The `postinstall` script runs `git clean -df fonts vendor modules/default` unconditionally. When `magicmirror` is installed as an npm dependency (e.g. `npm install magicmirror` or as a transitive dep in another project), npm runs `postinstall` in a directory that is **not** a git repository. This causes: ``` fatal: not a git repository (or any of the parent directories): .git ``` npm treats the non-zero exit as a failure → the entire installation aborts with `code 128`. This makes it impossible to use `magicmirror` as an npm dependency in any third-party project. The issue has been present since at least **v2.34.0**. In **v2.35.0** `modules/default` was added to the clean targets, but the root cause predates that change. ## Fix Added `scripts/postinstall.js` — a cross-platform Node.js script that guards the `git clean` call with a `git rev-parse --git-dir` check. - When running inside a real git repository: behaviour is identical to before. - When running outside one (e.g. installed as an npm package): step is silently skipped. `package.json` `postinstall` updated from the bare `git clean` call to: ```json "postinstall": "node scripts/postinstall.js" ``` This approach is cross-platform (Linux, macOS, Windows) and keeps the logic readable rather than inlined as a one-liner. Does this solve a related issue? No existing issue tracked. Discovered while using magicmirror as a devDependency in a companion tooling project — installation failed unconditionally on all platforms. Checklist - Targets the develop branch - No visual changes (script + package.json only) - node --run lint:prettier run — no changes needed for .js script --- package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package.json b/package.json index de94027a..75a1753d 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,6 @@ "sideEffects": true, "scripts": { "config:check": "node js/check_config.js", - "postinstall": "git clean -df fonts vendor modules/default", "install-mm": "npm install --no-audit --no-fund --no-update-notifier --only=prod --omit=dev", "install-mm:dev": "npm install --no-audit --no-fund --no-update-notifier && npx playwright install chromium", "lint:css": "stylelint 'css/**/*.css' 'defaultmodules/**/*.css' --fix",