fix: skip postinstall git clean when not in a git repository#4139
fix: skip postinstall git clean when not in a git repository#4139khassel merged 1 commit intoMagicMirrorOrg:developfrom
Conversation
|
@KristjanESPERANTO can you take a look on this please? I've found this issue while developing MagicMirror sandbox |
|
Looks good to me. But I'm not the only maintainer 🙂 @khassel, what do you think? Maybe we should take this opportunity to add a note to the script explaining that this is necessary for migrating from an older systems (<2.35.0) to a newer one, and that we can remove it in a few years. We wouldn't have been able to include a comment like that in package.json. |
|
As far as I'm concerned, it can be merged. Another option would be to remove the Its sole purpose is to remove folders whose contents have been moved and which would otherwise appear in For installations that haven't been migrated yet, that's just how it is; the user will have to clean it up themselves. |
|
I will update the update script to remove the old default module folder |
with this I think the best choice is to remove the @angeldeejay could you please update this PR accordingly? Thanks and sorry for the inconvenience... |
|
@khassel done! |
8801b44 to
810d852
Compare
|
@khassel @KristjanESPERANTO Do you want me to drop lock files changes and leave only package.json ones? |
|
Assumed yes. I'm guessing your pipelines update lock files by themselves |
What does this PR accomplish?
The
postinstallscript runsgit clean -df fonts vendor modules/defaultunconditionally. When
magicmirroris installed as an npm dependency(e.g.
npm install magicmirroror as a transitive dep in another project),npm runs
postinstallin a directory that is not a git repository.This causes:
npm treats the non-zero exit as a failure → the entire installation aborts
with
code 128. This makes it impossible to usemagicmirroras an npmdependency in any third-party project.
The issue has been present since at least v2.34.0. In v2.35.0
modules/defaultwas added to the clean targets, but the root causepredates that change.
Fix
Added
scripts/postinstall.js— a cross-platform Node.js script thatguards the
git cleancall with agit rev-parse --git-dircheck.package.jsonpostinstallupdated from the baregit cleancall to: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