diff --git a/src/config/plugin-loader.ts b/src/config/plugin-loader.ts index e2073fcf..7322ebb4 100644 --- a/src/config/plugin-loader.ts +++ b/src/config/plugin-loader.ts @@ -209,7 +209,7 @@ export default class PluginLoader { const userPJSONPath = join(opts.dataDir, 'package.json') debug('reading user plugins pjson %s', userPJSONPath) // ignore cache because the file might have changed within the same process (e.g. during a JIT plugin install) - const pjson = await readJson(userPJSONPath, true) + const pjson = await readJson(userPJSONPath, false) if (!pjson.oclif) pjson.oclif = {schema: 1} if (!pjson.oclif.plugins) pjson.oclif.plugins = [] await this.loadPlugins( diff --git a/src/util/fs.ts b/src/util/fs.ts index 7c8722cf..9538299b 100644 --- a/src/util/fs.ts +++ b/src/util/fs.ts @@ -63,11 +63,11 @@ const cache = new ProdOnlyCache() * Will throw an error if the file does not exist. * * @param path file path of JSON file - * @param ignoreCache if true, ignore cache and read file from disk + * @param useCache if false, ignore cache and read file from disk * @returns */ -export async function readJson(path: string, ignoreCache = false): Promise { - if (!ignoreCache && cache.has(path)) { +export async function readJson(path: string, useCache = true): Promise { + if (useCache && cache.has(path)) { return JSON.parse(cache.get(path)!) as T } @@ -82,12 +82,12 @@ export async function readJson(path: string, ignoreCache = false): * Will return undefined if the file does not exist. * * @param path file path of JSON file - * @param ignoreCache if true, ignore cache and read file from disk + * @param useCache if false, ignore cache and read file from disk * @returns or undefined */ -export async function safeReadJson(path: string, ignoreCache = false): Promise { +export async function safeReadJson(path: string, useCache = true): Promise { try { - return await readJson(path, ignoreCache) + return await readJson(path, useCache) } catch {} }