This is an automated email from the ASF dual-hosted git repository. erisu pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/cordova-ios.git
The following commit(s) were added to refs/heads/master by this push: new 6c925cf7 fix(plugins): Handle uninstalling multiple plugin assets (#1540) 6c925cf7 is described below commit 6c925cf71901becc88f9ca85fb422389e6e51969 Author: Darryl Pogue <dar...@dpogue.ca> AuthorDate: Sun Jun 8 21:56:54 2025 -0700 fix(plugins): Handle uninstalling multiple plugin assets (#1540) Try to safely clean up empty directories when uninstalling plugin assets without always forcibly removing the plugin directory itself. This should provide better handling for cases where plugins have multiple assets that get added to the plugin folder. Closes GH-1530. --- lib/plugman/pluginHandlers.js | 12 ++---------- tests/spec/unit/Plugman/pluginHandler.spec.js | 10 +++++----- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/lib/plugman/pluginHandlers.js b/lib/plugman/pluginHandlers.js index 3ce239a7..d9aec4c1 100644 --- a/lib/plugman/pluginHandlers.js +++ b/lib/plugman/pluginHandlers.js @@ -205,11 +205,9 @@ const handlers = { throw new CordovaError(generateAttributeError('target', 'asset', plugin.id)); } - removeFile(project.www, target); - removeFileF(path.resolve(project.www, 'plugins', plugin.id)); + removeFileAndParents(project.www, target); if (options && options.usePlatformWww) { - removeFile(project.platformWww, target); - removeFileF(path.resolve(project.platformWww, 'plugins', plugin.id)); + removeFileAndParents(project.platformWww, target); } } }, @@ -376,12 +374,6 @@ function linkFileOrDirTree (src, dest) { } } -// checks if file exists and then deletes. Error if doesn't exist -function removeFile (project_dir, src) { - const file = path.resolve(project_dir, src); - fs.rmSync(file); -} - // deletes file/directory without checking function removeFileF (file) { fs.rmSync(file, { recursive: true, force: true }); diff --git a/tests/spec/unit/Plugman/pluginHandler.spec.js b/tests/spec/unit/Plugman/pluginHandler.spec.js index e8ee1d0c..2fbeeefe 100644 --- a/tests/spec/unit/Plugman/pluginHandler.spec.js +++ b/tests/spec/unit/Plugman/pluginHandler.spec.js @@ -586,7 +586,7 @@ describe('ios plugin handler', () => { it('Test 043 : should put module to www only when options.usePlatformWww flag is not specified', () => { uninstall(jsModule, dummyPluginInfo, dummyProject); expect(fs.rmSync).toHaveBeenCalledWith(wwwDest, { recursive: true, force: true }); - expect(fs.rmSync).not.toHaveBeenCalledWith(platformWwwDest); + expect(fs.rmSync).not.toHaveBeenCalledWith(platformWwwDest, { recursive: true, force: true }); }); }); @@ -611,14 +611,14 @@ describe('ios plugin handler', () => { it('Test 044 : should put module to both www and platform_www when options.usePlatformWww flag is specified', () => { uninstall(asset, dummyPluginInfo, dummyProject, { usePlatformWww: true }); - expect(fs.rmSync).toHaveBeenCalledWith(wwwDest); - expect(fs.rmSync).toHaveBeenCalledWith(platformWwwDest); + expect(fs.rmSync).toHaveBeenCalledWith(wwwDest, { recursive: true, force: true }); + expect(fs.rmSync).toHaveBeenCalledWith(platformWwwDest, { recursive: true, force: true }); }); it('Test 045 : should put module to www only when options.usePlatformWww flag is not specified', () => { uninstall(asset, dummyPluginInfo, dummyProject); - expect(fs.rmSync).toHaveBeenCalledWith(wwwDest); - expect(fs.rmSync).not.toHaveBeenCalledWith(platformWwwDest); + expect(fs.rmSync).toHaveBeenCalledWith(wwwDest, { recursive: true, force: true }); + expect(fs.rmSync).not.toHaveBeenCalledWith(platformWwwDest, { recursive: true, force: true }); }); }); }); --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@cordova.apache.org For additional commands, e-mail: commits-h...@cordova.apache.org