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

Commit

Permalink
fix: limit warning about missing files attribute (#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
RasPhilCo authored Aug 15, 2019
1 parent 9a1d2c4 commit d84a238
Showing 1 changed file with 11 additions and 1 deletion.
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

0 comments on commit d84a238

Please sign in to comment.