From c850bbeb5f73b389c990a46dc2338512d0b311f6 Mon Sep 17 00:00:00 2001 From: RasPhilCo Date: Tue, 14 Apr 2020 15:25:28 -0700 Subject: [PATCH] fix: do not load oclif.devPlugins in production (#104) --- src/config.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/config.ts b/src/config.ts index 5fb2f836..3122a2cf 100644 --- a/src/config.ts +++ b/src/config.ts @@ -142,6 +142,15 @@ function channelFromVersion(version: string) { return (m && m[1]) || 'stable' } +function hasManifest(p: string): boolean { + try { + require(p) + return true + } catch { + return false + } +} + export class Config implements IConfig { _base = `${_pjson.name}@${_pjson.version}` @@ -265,6 +274,8 @@ export class Config implements IConfig { async loadDevPlugins() { if (this.options.devPlugins !== false) { + // do not load oclif.devPlugins in production + if (hasManifest(path.join(this.root, 'oclif.manifest.json'))) return try { const devPlugins = this.pjson.oclif.devPlugins if (devPlugins) await this.loadPlugins(this.root, 'dev', devPlugins)