From 55e9aabcb86fb0001e2de5b5b2a718014986cc6a Mon Sep 17 00:00:00 2001 From: Cristian Dominguez <6853656+cristiand391@users.noreply.github.com> Date: Wed, 4 Sep 2024 21:43:10 -0300 Subject: [PATCH] feat: add `refresh-cache` hook (#7) --- package.json | 6 +++++- src/hooks/refresh-cache.ts | 8 ++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 src/hooks/refresh-cache.ts diff --git a/package.json b/package.json index 407d32e..53f367f 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,11 @@ "typescript": "^5.3.3" }, "oclif": { - "commands": "./lib/commands" + "commands": "./lib/commands", + "hooks": { + "plugins:postinstall": "./lib/hooks/refresh-cache.js", + "plugins:postuninstall": "./lib/hooks/refresh-cache.js" + } }, "prettier": { "singleQuote": true diff --git a/src/hooks/refresh-cache.ts b/src/hooks/refresh-cache.ts new file mode 100644 index 0000000..a07f0b6 --- /dev/null +++ b/src/hooks/refresh-cache.ts @@ -0,0 +1,8 @@ +import {Hook} from '@oclif/core' + +const hook: Hook<'refresh'> = async function (opts) { + // this `config` instance already have installed/uninstalled plugins loaded + await opts.config.runCommand('fzf-cmp', ['--refresh-cache']) +} + +export default hook