Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface ScopedGhostService

Hierarchy

  • ScopedGhostService

Index

Methods

deleteFile

  • deleteFile(rootFolder: string, file: string): Promise<void>
  • Parameters

    • rootFolder: string
    • file: string

    Returns Promise<void>

directoryListing

  • directoryListing(rootFolder: string, fileEndingPattern: string, exclude?: string | string[], includeDotFiles?: undefined | false | true): Promise<string[]>
  • List all the files matching the ending pattern in the folder

    example

    bp.ghost.forBot('welcome-bot').directoryListing('./questions', '*.json')

    Parameters

    • rootFolder: string

      Folder relative to the scoped parent

    • fileEndingPattern: string

      The pattern to match. Don't forget to include wildcards!

    • Optional exclude: string | string[]

      The pattern to match excluded files.

    • Optional includeDotFiles: undefined | false | true

      Whether or not to include files starting with a dot (normally disabled files)

    Returns Promise<string[]>

fileExists

  • fileExists(rootFolder: string, file: string): Promise<boolean>
  • Parameters

    • rootFolder: string
    • file: string

    Returns Promise<boolean>

onFileChanged

  • Starts listening on all file changes (deletion, inserts and updates) callback will be called for every change To stop listening, call the remove() method of the returned ListenHandle

    Parameters

    • callback: function
        • (filePath: string): void
        • Parameters

          • filePath: string

          Returns void

    Returns ListenHandle

readFileAsBuffer

  • readFileAsBuffer(rootFolder: string, file: string): Promise<Buffer>
  • Parameters

    • rootFolder: string
    • file: string

    Returns Promise<Buffer>

readFileAsObject

  • readFileAsObject<T>(rootFolder: string, file: string): Promise<T>
  • Type parameters

    • T

    Parameters

    • rootFolder: string
    • file: string

    Returns Promise<T>

readFileAsString

  • readFileAsString(rootFolder: string, file: string): Promise<string>
  • Parameters

    • rootFolder: string
    • file: string

    Returns Promise<string>

renameFile

  • renameFile(rootFolder: string, fromName: string, toName: string): Promise<void>
  • Parameters

    • rootFolder: string
    • fromName: string
    • toName: string

    Returns Promise<void>

upsertFile

  • upsertFile(rootFolder: string, file: string, content: string | Buffer, options?: UpsertOptions): Promise<void>
  • Insert or Update the file at the specified location

    Parameters

    • rootFolder: string

      Folder relative to the scoped parent

    • file: string

      The name of the file

    • content: string | Buffer

      The content of the file

    • Optional options: UpsertOptions

    Returns Promise<void>

Generated using TypeDoc