From cbda9361ac1a0f0d47110331145eb022b48a2d9b Mon Sep 17 00:00:00 2001 From: Cristian Dominguez Date: Tue, 30 Jul 2024 16:20:04 -0300 Subject: [PATCH] feat: add `refresh-cache` hook --- 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 282f0297..d8fc592d 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,11 @@ "devPlugins": [ "@oclif/plugin-help" ], - "flexibleTaxonomy": true + "flexibleTaxonomy": true, + "hooks": { + "plugins:postinstall": "./lib/hooks/refresh-cache.js", + "plugins:postuninstall": "./lib/hooks/refresh-cache.js" + } }, "repository": "oclif/plugin-autocomplete", "scripts": { diff --git a/src/hooks/refresh-cache.ts b/src/hooks/refresh-cache.ts new file mode 100644 index 00000000..f4f2f45e --- /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('autocomplete:create') +} + +export default hook