Skip to content

Script for plugin hook "after_plugin_rm" does not work #629

@trayvon2017

Description

@trayvon2017

Bug Report

Problem

I want to do something after plugin is removed.
I have tried to use after_plugin_rm hook in "plugin.xml" but it did not work.

What is expected to happen?

Script for after_plugin_rm need to be executed

What does actually happen?

No scripts found for hook after_plugin_rm.

Information

Scripts for hooks(after_plugin_addbefore_plugin_rm and before_plugin_uninstall) are all performed normally.
After removing the plugin, the commandline outputs 'No scripts found for hook "after_plugin_rm"'

I think It may be caused by the plugin code(include the script for "after_plugin_rm" hook) being removed before "after_plugin_rm" hook.

I built a simple cordova plugin repository for test.

Command or Code

Partial code in plugin.xml, full plugin code is here

<plugin id="com.trayvon2017.plugindemo" version="1.0.0" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
	...
	<platform name="android">
                <hook type="after_plugin_add" src="scripts/after_plugin_add.js" />
		<hook type="before_plugin_rm" src="scripts/before_plugin_rm.js" />
		<hook type="before_plugin_uninstall" src="scripts/before_plugin_uninstall.js" />
		<hook type="after_plugin_rm" src="scripts/after_plugin_rm.js" />
        ...

add plugin

cordova plugin add https://github.com/trayvon2017/plugindemo.git
outputs:

Installing "com.trayvon2017.plugindemo" for android
Installing "com.trayvon2017.plugindemo" for ios
Adding com.trayvon2017.plugindemo to package.json
after_plugin_add waited 1004 ms

remove plugin

cordova plugin remove com.trayvon2017.plugindemo --verbose
outputs:

Executing script found in plugin com.trayvon2017.plugindemo for hook "before_plugin_rm": plugins/com.trayvon2017.plugindemo/scripts/before_plugin_rm.js
before_plugin_rm waited 1003 ms
Calling plugman.uninstall on plugin "com.trayvon2017.plugindemo" for platform "android"
Finding scripts for "before_plugin_uninstall" hook from plugin com.trayvon2017.plugindemo on android platform only.
Executing script found in plugin com.trayvon2017.plugindemo for hook "before_plugin_uninstall": plugins/com.trayvon2017.plugindemo/scripts/before_plugin_uninstall.js
before_plugin_uninstall waited 1003 ms
Uninstalling com.trayvon2017.plugindemo from android
Loaded API for android project /Users/trayvon/code/cordova-projects/hello/platforms/android/cordova/Api.js
Beginning processing of action stack for android project...
Action stack processing complete.
Calling plugman.uninstall on plugin "com.trayvon2017.plugindemo" for platform "ios"
Finding scripts for "before_plugin_uninstall" hook from plugin com.trayvon2017.plugindemo on ios platform only.
No scripts found for hook "before_plugin_uninstall".
Uninstalling com.trayvon2017.plugindemo from ios
Loaded API for ios project /Users/trayvon/code/cordova-projects/hello/platforms/ios/cordova/Api.js
Beginning processing of action stack for ios project...
Action stack processing complete.
pods.json found in platforms/ios
Podfile found in platforms/ios
Removing "com.trayvon2017.plugindemo"
Deleted plugin "com.trayvon2017.plugindemo"
Running command: npm uninstall com.trayvon2017.plugindemo --save-dev
Command finished with error code 0: npm uninstall,com.trayvon2017.plugindemo,--save-dev
Removing com.trayvon2017.plugindemo from package.json
Removing plugin com.trayvon2017.plugindemo from fetch.json
No scripts found for hook "after_plugin_rm".

Environment, Platform, Device

Version information

Cordova CLI: 11.0.0 and 12.0.0
Cordova Platforms: android
Operating System: macos 13.5.2

Checklist

  • I searched for existing GitHub issues
  • I updated all Cordova tooling to most recent version
  • I included all the necessary information above

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions