Constructor
new Plugin(pkgName, app)
Constructor.
| Name | Type | Description |
|---|---|---|
pkgName | string | Package name (the one in package.json) |
app | Object | App instance reference. Usefull to call app method inside a plugin |
- Source
Members
(readonly) alias :string
Plugin alias. Derived plugin must provide its own, unique alias. If it left blank, Bajo will provide this automatically (by using the kebab-cased version of plugin name).
- string
- Source
app :App
Reference to the app instance
- Source
config :Object
Configuration object.
- Object
- Source
- See
- config
log :Log
Shortcut to App#log with prefix parameter set to this plugin namespace.
- Source
ns :string
Namespace (ns) or plugin's name. It is the camel cased version of plugin's package name.
- string
- Source
pkgName :string
Package name, the one from package.json.
- string
- Source
Methods
(async) dispose() → {Promise.<void>}
Dispose internal references.
- Source
- Type:
- Promise.<void>
dump(…args) → {void}
Alias to this.app.dump().
| Name | Type | Attributes | Description |
|---|---|---|---|
args | any | <repeatable> | Arguments |
- Source
- Type:
- void
error(msg, …argsopt) → {Err}
Create an instance of Err object.
| Name | Type | Attributes | Description |
|---|---|---|---|
msg | string | Error message | |
args | any | <optional> <repeatable> | Argument variables you might want to add to the error object |
- Source
Err instance
- Type:
- Err
fatal(msg, …argsopt) → {void}
Create an instance of Err object, display it on screen and then force terminate the app.
| Name | Type | Attributes | Description |
|---|---|---|---|
msg | string | Error message | |
args | any | <optional> <repeatable> | Argument variables you might want to add to the error object |
- Source
- Type:
- void
getConfig(pathopt, optionsopt) → {Object}
Get plugin's config value.
| Name | Type | Attributes | Default | Description | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
path | string | <optional> | dot separated config path (think of lodash's 'get'). If not provided, the full config will be given | |||||||||||||||||||||
options | Object | <optional> | {} | Options object Properties
|
- Source
Returned object. If no path provided, the whole config object is returned
- Type:
- Object
getPkgInfo(diropt, keysopt) → {Object}
Get package info.
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
dir | string | <optional> | Package directory. Defaults to the current plugin's package dir | |
keys | Array | <optional> | ['name', 'version', 'description', 'author', 'license', 'homepage', 'bajo'] | Field keys to be use. Set empty to use all keys |
- Source
Package info object
- Type:
- Object
selfBind(names) → {void}
Force bind methods to self (this).
| Name | Type | Description |
|---|---|---|
names | Array.<string> | Method's names |
- Source
- Type:
- void
t(text, …params) → {string}
Translate text and interpolate with given args.
Shortcut to App#t with ns parameter set to this plugin namespace.
| Name | Type | Attributes | Description |
|---|---|---|---|
text | string | Text to translate | |
params | any | <repeatable> | Variables to interpolate to |
- Source
- Type:
- string
te(text, …params) → {string}
Check whether translation text/key exists.
Shortcut to App#te with ns parameter set to this plugin namespace.
| Name | Type | Attributes | Description |
|---|---|---|---|
text | string | Text to translate | |
params | any | <repeatable> | Variables to interpolate to |
- Source
- Type:
- string