diff --git a/site/install.test.mjs b/site/install.test.mjs index 4c9f7b157..b6db00b90 100644 --- a/site/install.test.mjs +++ b/site/install.test.mjs @@ -211,6 +211,11 @@ test("--uninstall takes off the command, menu entry, icon and magpie:// default, assert.equal(u.status, 0, u.stderr); for (const p of [r.exe, r.entry, r.icon]) assert.equal(existsSync(p), false, p); assert.equal(readFileSync(r.mime, "utf8"), "[Default Applications]\ntext/html=firefox.desktop\n"); + // with no line of the user's, the list xdg-mime made goes with it + const bare = installedDesktop(t); + const bu = bare.run(["--uninstall"]); + assert.equal(bu.status, 0, bu.stderr); + assert.equal(existsSync(bare.mime), false); assert.ok(existsSync(r.settings), "the settings stay"); assert.equal(r.calls(), "", "magpie isn't asked to uninstall"); assert.equal(u.calls.length, 0, "nothing is downloaded"); @@ -260,7 +265,7 @@ test("--purge has magpie uninstall itself first, then takes off the install", (t assert.match(r.calls(), /^uninstall --yes$/m); for (const p of [r.exe, r.entry, r.icon, r.settings]) assert.equal(existsSync(p), false, p); // magpie took the menu entry itself; its icon and magpie:// default go too - assert.doesNotMatch(readFileSync(r.mime, "utf8"), /magpie/); + assert.equal(existsSync(r.mime), false); assert.doesNotMatch(u.stdout, /kept your settings/); // magpie failing to: the command stays, to run it again diff --git a/site/public/install.sh b/site/public/install.sh index 3adb30ef5..0e3bdafe8 100644 --- a/site/public/install.sh +++ b/site/public/install.sh @@ -152,6 +152,8 @@ if [ -n "$uninstall" ]; then if [ -f "$list" ] && grep -qx 'x-scheme-handler/magpie=magpie\.desktop;\{0,1\}' "$list"; then grep -vx 'x-scheme-handler/magpie=magpie\.desktop;\{0,1\}' "$list" > "$list.magpie-new" || true mv "$list.magpie-new" "$list" + # a list left with no entry at all (the one xdg-mime made) goes + grep -qv -e '^\[.*\]$' -e '^[[:space:]]*$' "$list" || rm -f "$list" removed=1; say "removed magpie:// from $list" fi if [ -d "$apps" ] && ! ls "$apps" | grep -q '\.desktop$'; then