External helpers you can use by importing its file directly
- Source
Methods
(static) currentLoc(metaImport) → {Object}
Get current directory & file. An attempt to brings back the old __dirname
and __filename
to the ES6 era.
Returns object with the following keys:
__dirname
(aliases todir
) - current directory name__filename
(aliases tofile
) - current file path
Example:
const { importModule } = this.app.bajo
const currentLoc = await importModule('bajo:/lib/current-loc.js')
const { __dirname, __filename } = currentLoc(import.meta)
console.log(__dirname, __filename)
Name | Type | Description |
---|---|---|
metaImport | Object |
|
- Source
- Type:
- Object
(async, static) importModule(file, optionsopt) → {any}
Import file/module from any loaded plugins
Example: your plugin structure looks like this
|- src
| |- lib
| | |- my-module.js
|- index.js
|- package.json
And now this is how to import my-module.js
:
const { importModule } = this.app.bajo
const myModule = await importModule('myPlugin:/src/lib/my-module.js')
Name | Type | Attributes | Default | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
file | TNsPathPairs | File to import | ||||||||||||||||||||||
options | Object | <optional> | {} | Options Properties
|
- Source
- Type:
- any
(async, static) parseArgsArgv(useParseropt) → {Object}
Name | Type | Attributes | Description |
---|---|---|---|
useParser | boolean | <optional> | If |
- Source
An object containing args
and argv
- Type:
- Object
(static) parseEnv() → {Object}
Parse environment variables. See envVars for examples
- Source
- See
- Type:
- Object
(static) resolvePath(file, asFileUrlopt) → {string}
Resolve file name to filesystem's path. Windows path separator \
is normalized to Unix's /
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
file | string | File to resolve | ||
asFileUrl | boolean | <optional> | false | Return as file URL format |
- Source
- Type:
- string
(static) shim()
Function to attach some of the methods needed but probably not provided by your node installation:
String.prototype.replaceAll
String.prototype.splice
- Source