mirror of
https://github.com/MichMich/MagicMirror.git
synced 2026-06-04 10:19:29 +00:00
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
This commit is contained in:
committed by
GitHub
parent
623e1e23d1
commit
b474198267
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user