Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "util"

Index

Type aliases

SpawnAsyncOptions

SpawnAsyncOptions: SpawnOptions

Possible values for options of 'spawnAsync()' function.

SpawnOptions

SpawnOptions: SpawnOptions | SpawnSyncOptionsWithBufferEncoding

Possible values for options of 'spawn()' function.

Variables

Const chalk

chalk: any = require('chalk')

Functions

asArray

  • asArray<T>(val: T | T[], noEmpty?: boolean): T[]
  • Keeps sure a value is an array.

    Type parameters

    • T

    Parameters

    • val: T | T[]

      The input value.

    • Default value noEmpty: boolean = true

    Returns T[]

    The output value.

async

  • async<TResult>(action: (...args: any[]) => TResult): Promise<TResult>
  • Runs an action async.

    Type parameters

    • TResult

    Parameters

    • action: (...args: any[]) => TResult

      The action to invoke.

        • (...args: any[]): TResult
        • Parameters

          • Rest ...args: any[]

          Returns TResult

    Returns Promise<TResult>

    The promise with the resumt of the action.

colorize

  • colorize(str: any, color?: any, reset?: boolean): string
  • Colorizes a string for console output.

    Parameters

    • str: any

      The value to colorize.

    • Default value color: any = "white"

      The color.

    • Default value reset: boolean = true

    Returns string

    The colorized string.

compareValuesBy

  • compareValuesBy<T, V>(x: T, y: T, selector: (i: T) => V): number
  • Compares two values for sorting, by using a selector.

    Type parameters

    • T

    • V

    Parameters

    • x: T

      The first value.

    • y: T

      The second value.

    • selector: (i: T) => V

      The function, that selects the value to compare.

        • (i: T): V
        • Parameters

          • i: T

          Returns V

    Returns number

    The soirt value.

eGO

  • eGO(val?: any): string
  • Handles a value as string and adds colors to each 'e.GO' expression inside it for console output.

    Parameters

    • Default value val: any = "e.GO"

    Returns string

    The output value.

exists

  • exists(p: fs.PathLike): Promise<boolean>
  • Checks if a path exists.

    Parameters

    • p: fs.PathLike

      The path to check.

    Returns Promise<boolean>

    The promise, that indicates, if path exists or not.

getCWD

  • Extracts the current working directory from an object.

    Parameters

    • obj: WithCWD

      The object with the data.

    Returns string

    The extracted data.

getEGOFolder

  • getEGOFolder(create?: boolean): string
  • Returns the possible '.ego' folder inside the user's home directory.

    Parameters

    • Default value create: boolean = true

    Returns string

    The full path of the '.ego' folder.

getMimeType

  • getMimeType(p: any): string
  • Returns the MIME type by file path.

    Parameters

    • p: any

      The (file) path.

    Returns string

    The mime type.

getResourcePath

  • getResourcePath(p: any): string
  • Returns the full path inside the 'res' folder.

    Parameters

    • p: any

      The relative path.

    Returns string

    The full path.

getSTDIO

  • getSTDIO(obj: WithVerbose): child_process.StdioOptions
  • Returns the value for an spawn.stdio property.

    Parameters

    Returns child_process.StdioOptions

    The value for the property.

globalModuleExists

  • globalModuleExists(moduleId: string): boolean
  • Checks if a global module exists.

    Parameters

    • moduleId: string

      The ID of the module.

    Returns boolean

    Module exists or not.

loadEJS

  • loadEJS(p: any, data?: Data): string
  • Loads an EJS template from 'res' folder.

    Parameters

    • p: any

      The relative path inside 'res/templates' without '.ejs' extension.

    • Optional data: Data

    Returns string

    The rendered template.

loadEJSAsync

  • loadEJSAsync(p: any, data?: Data): Promise<string>
  • Loads an EJS template from 'res' folder.

    Parameters

    • p: any

      The relative path inside 'res/templates' without '.ejs' extension.

    • Optional data: Data

    Returns Promise<string>

    The promise with the rendered template.

loadResource

  • loadResource(p: any): Buffer
  • Loads a file from 'res' folder.

    Parameters

    • p: any

      The relative path of the resource.

    Returns Buffer

    The loaded data.

loadResourceAsync

  • loadResourceAsync(p: any): Promise<Buffer>
  • Loads a file from 'res' folder.

    Parameters

    • p: any

      The relative path of the resource.

    Returns Promise<Buffer>

    The promise with the loaded data.

sortObjectByKeys

  • sortObjectByKeys<T>(obj: T): T
  • Creates a clone of an object and sorts the keys.

    Type parameters

    • T

    Parameters

    • obj: T

      The input object.

    Returns T

    The output object.

spawn

  • spawn(command: any, args?: any[], opts?: SpawnOptions): SpawnSyncReturns<Buffer>
  • Spawns a new process.

    Parameters

    • command: any

      The command.

    • Optional args: any[]
    • Optional opts: SpawnOptions

    Returns SpawnSyncReturns<Buffer>

    The result of the execution.

spawnAsync

  • Spawns a new process (async).

    Parameters

    Returns Promise<SpawnAsyncResult>

    The promise with the result of the execution.

toBooleanSafe

  • toBooleanSafe(val: any, defaultValue?: any): boolean
  • Returns a value as boolean.

    Parameters

    • val: any

      The input value.

    • Optional defaultValue: any

    Returns boolean

    The input value as boolean.

toBufferSafe

  • toBufferSafe(data: any): Buffer
  • Converts data to a buffer (if needed).

    Parameters

    • data: any

      The input data.

    Returns Buffer

    The output data.

toStringSafe

  • toStringSafe(val: any): string
  • Converts a value to a string (if needed).

    Parameters

    • val: any

      The input value.

    Returns string

    The output value.

waitForEnter

  • waitForEnter(text?: any): Promise<void>
  • Waits for ENTER key (in the console).

    Parameters

    • Default value text: any = ""

    Returns Promise<void>

withSpinner

  • withSpinner<TResult>(text: any, action?: (spinner: Ora) => TResult): TResult
  • Executes an action for a spinner.

    Type parameters

    • TResult

    Parameters

    • text: any

      The initial text.

    • Optional action: (spinner: Ora) => TResult
        • (spinner: Ora): TResult
        • Parameters

          • spinner: Ora

          Returns TResult

    Returns TResult

    The result of the action.

withSpinnerAsync

  • withSpinnerAsync<TResult>(text: any, action?: (spinner: Ora) => PromiseLike<TResult>): Promise<TResult>
  • Executes an action for a spinner (async).

    Type parameters

    • TResult

    Parameters

    • text: any

      The initial text.

    • Optional action: (spinner: Ora) => PromiseLike<TResult>
        • (spinner: Ora): PromiseLike<TResult>
        • Parameters

          • spinner: Ora

          Returns PromiseLike<TResult>

    Returns Promise<TResult>

    The promise with the result of the action.

write

  • write(msg: any): void
  • Writes an output message.

    Parameters

    • msg: any

      The message to write.

    Returns void

writeErr

  • writeErr(msg: any): void
  • Writes an output message to error stream.

    Parameters

    • msg: any

      The message to write.

    Returns void

writeErrLine

  • writeErrLine(msg?: any): void
  • Writes an (optional) output message to error stream and adds a new line.

    Parameters

    • Default value msg: any = ""

    Returns void

writeLine

  • writeLine(msg?: any): void
  • Writes an (optional) output message and adds a new line.

    Parameters

    • Default value msg: any = ""

    Returns void

Generated using TypeDoc