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

fix: limit warning about missing files attribute #86

Merged
merged 1 commit into from
Aug 15, 2019
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
12 changes: 11 additions & 1 deletion src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,15 @@ export interface IPlugin {

const _pjson = require('../package.json')

const hasManifest = function (p: string): boolean {
try {
require(p)
return true
} catch {
return false
}
}

export class Plugin implements IPlugin {
// static loadedPlugins: {[name: string]: Plugin} = {}
_base = `${_pjson.name}@${_pjson.version}`
Expand Down Expand Up @@ -106,7 +115,8 @@ export class Plugin implements IPlugin {
this.name = this.pjson.name
const pjsonPath = path.join(root, 'package.json')
if (!this.name) throw new Error(`no name in ${pjsonPath}`)
if (!this.pjson.files) this.warn(`files attribute must be specified in ${pjsonPath}`)
const isProd = hasManifest(path.join(root, 'oclif.manifest.json'))
if (!isProd && !this.pjson.files) this.warn(`files attribute must be specified in ${pjsonPath}`)
this._debug = Debug(this.name)
this.version = this.pjson.version
if (this.pjson.oclif) {
Expand Down