From cc73cb51da6a2d5c49e414107aef44b0830bb78d Mon Sep 17 00:00:00 2001 From: Jeff Dickey <216188+jdxcode@users.noreply.github.com> Date: Sat, 26 May 2018 10:59:51 -0700 Subject: [PATCH] fix: warn if files attribute is not specified --- src/plugin.ts | 5 ++++- test/fixtures/typescript/package.json | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/plugin.ts b/src/plugin.ts index f2910f83..9dce0015 100644 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -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) { @@ -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)) } diff --git a/test/fixtures/typescript/package.json b/test/fixtures/typescript/package.json index 2fbaa6f3..5f5b178d 100644 --- a/test/fixtures/typescript/package.json +++ b/test/fixtures/typescript/package.json @@ -1,6 +1,7 @@ { "name": "ts-plugin", "private": true, + "files": [], "oclif": { "commands": "./lib/commands", "hooks": {