Skip to content

Commit b474198

Browse files
authored
fix: skip postinstall git clean when not in a git repository (#4139)
## 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
1 parent 623e1e2 commit b474198

1 file changed

Lines changed: 0 additions & 1 deletion

File tree

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
"sideEffects": true,
5050
"scripts": {
5151
"config:check": "node js/check_config.js",
52-
"postinstall": "git clean -df fonts vendor modules/default",
5352
"install-mm": "npm install --no-audit --no-fund --no-update-notifier --only=prod --omit=dev",
5453
"install-mm:dev": "npm install --no-audit --no-fund --no-update-notifier && npx playwright install chromium",
5554
"lint:css": "stylelint 'css/**/*.css' 'defaultmodules/**/*.css' --fix",

0 commit comments

Comments
 (0)