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

Commit

Permalink
fix: warn if files attribute is not specified
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed May 26, 2018
1 parent 4f32e5a commit cc73cb5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ export class Plugin implements IPlugin {
this._debug('reading %s plugin %s', this.type, root)
this.pjson = await loadJSON(path.join(root, 'package.json')) as any
this.name = this.pjson.name
if (!this.name) throw new Error(`no name in ${path.join(root, 'package.json')}`)
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}`)
this._debug = Debug(this.name)
this.version = this.pjson.version
if (this.pjson.oclif) {
Expand Down Expand Up @@ -217,6 +219,7 @@ export class Plugin implements IPlugin {

protected warn(err: any, scope?: string) {
if (this.warned) return
if (typeof err === 'string') err = new Error(err)
process.emitWarning(this.addErrorScope(err, scope))
}

Expand Down
1 change: 1 addition & 0 deletions test/fixtures/typescript/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "ts-plugin",
"private": true,
"files": [],
"oclif": {
"commands": "./lib/commands",
"hooks": {
Expand Down

0 comments on commit cc73cb5

Please sign in to comment.