Members
(inner, constant) addToProcess
- Description:
Loop over the passed in ENVs, and add them to the current process Add them to the process.env if they don't already exist
- Source:
Loop over the passed in ENVs, and add them to the current process Add them to the process.env if they don't already exist
(inner, constant) inDocker
- Description:
Checks if the current process is running in a docker container
- Source:
Checks if the current process is running in a docker container
Methods
(inner) docGroup() → {Boolean}
- Description:
Checks if docker is in the process group
- Source:
Returns:
true if the docker group exists
- Type
- Boolean
(inner) dockEnv() → {Boolean}
- Description:
Checks if the /.dockerenv file exists
- Source:
Returns:
true if the check for /.dockerenv does not throw
- Type
- Boolean
(inner) findProc(procName, opts) → {Object}
- Description:
Searches for a currently process by name, and returns it if found
- Source:
Parameters:
Name | Type | Description |
---|---|---|
procName |
String | The executable name to check |
opts |
Object | Options to configure how the method runs |
Returns:
- Status of the found process
- Type
- Object
(inner) getOS() → {String}
- Description:
Gets and normalizes the current operating system
- Source:
Returns:
- The current operating system
- Type
- String
(inner) getRelativePath(pathToModule) → {String}
- Description:
Gets the relative path from the passed in pathToModule
- Source:
Parameters:
Name | Type | Description |
---|---|---|
pathToModule |
String | Location to get the relative path from |
Returns:
- Update pathToModule string as a relative path
- Type
- String
(inner) loadByType(foundModule, params) → {any}
- Description:
Checks if the module is a function and calls it
Or if it's an object return it
- Source:
Parameters:
Name | Type | Description |
---|---|---|
foundModule |
Object | Array | function | module loaded from require |
params |
any | arguments to pass to the module if it's a function |
Returns:
- Loaded modules or undefined
- Type
- any
(inner) loadModule(pathsToModule, configopt, params) → {Object}
- Description:
Use nodes require method to load a module by file path.
If the path does not exist check the altPaths to see if any of those paths exist
If it's a function call it and pass in the params array
Module path is relative to the caller, NOT this function file location!
- Source:
Examples
const packageConfig = loadModule('../package.json')
const packageConfig = loadModule([ './package.json', '../package.json', '../../package.json', ])
const packageConfig = loadModule([ './package.json' ], { rootDir: 'path to root directory' })
const packageConfig = loadModule([ './functionModule' ], {}, param1, param2, param2)
// Module will be called if it's a function, and param1, param2, param2 will be passed in
Parameters:
Name | Type | Attributes | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
pathsToModule |
Array | String | Potential paths to a module |
|||||||||||||
config |
Object |
<optional> |
settings to load the module Properties
|
||||||||||||
params |
Array | undefined | Arguments to pass the the module when called if it's a function |
Returns:
- Loaded module object
- Type
- Object
(inner) loopLoad(pathsToModule, config, params) → {Object}
- Description:
Loops through the pathsToModule array trying to require them
- Source:
Parameters:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
pathsToModule |
Array | Potential paths to a module |
|||||||||
config |
Object | settings to load the module Properties
|
|||||||||
params |
Array | Arguments to pass the the module when called if it's a function |
Returns:
- Loaded module object
- Type
- Object
(inner) requireModule(pathToModule, config) → {Object|function}
- Description:
Use nodes require method to load a module by file path.
Use the rootDir to load the module if it's passed in
If rootDir + pathToModule fails, will try to load the module without the rootDir
- Source:
Parameters:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
pathToModule |
String | Path to the module to load |
|||||||||
config |
Object | settings to load the module Properties
|
Returns:
- Loaded module
- Type
- Object | function
(inner) resolvePath(location) → {string}
- Description:
Converts the local part of the passed in location to an absolute path
- Source:
Parameters:
Name | Type | Description |
---|---|---|
location |
string | Path to be resolved |
Returns:
- Resolved location
- Type
- string
(inner) tryCatch(cb) → {Boolean}
- Description:
Wraps a method with try catch, and returns false when it throws
- Source:
Parameters:
Name | Type | Description |
---|---|---|
cb |
function | Method to wrap try catch around |
Returns:
true if the cb returns a truthy response
- Type
- Boolean
(inner) tryRequire(filePath) → {Promise.<*>}
- Description:
Tries to asynchronously require the path, returning null if unable to. Does not throw.
- Source:
Example
const module = await tryRequire('/keg/tap/foo/bar.js')
if (!module) console.log('bar.js module does not exist')
Parameters:
Name | Type | Description |
---|---|---|
filePath |
String | path to file. You should use an absolute path |
Returns:
the export at path, if it exists, null otherwise
- Type
- Promise.<*>
(inner) tryRequireSync(filePath) → (nullable) {*}
- Description:
Tries to synchronously require the path, returning null if unable to. Does not throw.
- Source:
Example
const module = tryRequireSync('/keg/tap/foo/bar.js')
if (!module) console.log('bar.js module does not exist')
Parameters:
Name | Type | Description |
---|---|---|
filePath |
String | path to file. You should use an absolute path |
Returns:
the export at path, if it exists, null otherwise
- Type
- *