From 8e219113f8f2f9ff008a6562ed176290764617b8 Mon Sep 17 00:00:00 2001 From: Huan LI Date: Wed, 1 Apr 2020 12:06:27 +0800 Subject: [PATCH] add name() method for getting the provider npm name (#89) --- src/puppet.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/puppet.ts b/src/puppet.ts index f4b433f9..b8f37f57 100644 --- a/src/puppet.ts +++ b/src/puppet.ts @@ -133,7 +133,7 @@ export abstract class Puppet extends EventEmitter { /** * childPkg stores the `package.json` that the NPM module who extends the `Puppet` */ - private readonly childPkg: undefined | normalize.Package + private readonly childPkg: normalize.Package /** * Throttle Reset Events @@ -455,14 +455,18 @@ export abstract class Puppet extends EventEmitter { */ public abstract ding (data?: string) : void + /** + * Get the NPM name of the Puppet + */ + public name () { + return this.childPkg.name + } + /** * Get version from the Puppet Implementation */ public version (): string { - if (this.childPkg) { - return this.childPkg.version - } - return '0.0.0' + return this.childPkg.version } /**