Skip to content
This repository has been archived by the owner on Aug 22, 2023. It is now read-only.

fix: do not load oclif.devPlugins in production #104

Merged
merged 1 commit into from
Apr 14, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`

Expand Down Expand Up @@ -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)
Expand Down