Options
All
  • Public
  • Public/Protected
  • All
Menu

This class will handle common sequences of node I/O and issue messages / throw errors as neccessary.

export

Hierarchy

  • IO

Index

Properties

Static Readonly FILE_DELIM

FILE_DELIM: string = path.posix.sep

File delimiter

deprecated

Use path.posix.sep instead or path.sep for better cross-platform support

static
memberof

IO

Static Readonly OS_LINUX

OS_LINUX: "linux" = "linux"

Linux OS identifier

static
memberof

IO

Static Readonly OS_MAC

OS_MAC: "darwin" = "darwin"

Mac OS identifier

static
memberof

IO

Static Readonly OS_WIN32

OS_WIN32: "win32" = "win32"

Windows OS identifier

static
memberof

IO

Static Readonly UTF8

UTF8: "utf8" = "utf8"

UTF8 identifier

static
memberof

IO

Methods

Static createDirSync

  • createDirSync(dir: string): void

Static createDirsSync

  • createDirsSync(dir: string): void
  • Create all needed directories for an input directory in the form of: first/second/third where first will contain director second and second will contain directory third

    static
    memberof

    IO

    Parameters

    • dir: string

      directory to create all sub directories for

    Returns void

Static createDirsSyncFromFilePath

  • createDirsSyncFromFilePath(filePath: string): void
  • Create all necessary directories for a fully qualified file and its path, for example, if filePath = oneDir/twoDir/threeDir/file.txt, oneDir, twoDir, and threeDir will be created.

    static
    memberof

    IO

    Parameters

    • filePath: string

    Returns void

    [description]

Static createFileSync

  • createFileSync(file: string): void

Static createReadStream

  • createReadStream(file: string): Readable
  • Create a Node.js Readable stream from a file

    memberof

    IO

    Parameters

    • file: string

      the file from which to create a read stream

    Returns Readable

    Buffer - the content of the file

Static createSymlinkToDir

  • createSymlinkToDir(newSymLinkPath: string, existingDirPath: string): void
  • Create a symbolic link to a directory. If the symbolic link already exists, re-create it with the specified target directory.

    Parameters

    • newSymLinkPath: string

      the path new symbolic link to be created

    • existingDirPath: string

      the path the existing directory that we will link to

    Returns void

Static createWriteStream

  • createWriteStream(file: string): Writable
  • Create a Node.js Readable stream from a file

    memberof

    IO

    Parameters

    • file: string

      the file from which to create a read stream

    Returns Writable

    Buffer - the content of the file

Static deleteDir

  • deleteDir(dir: string): void

Static deleteDirTree

  • deleteDirTree(pathToTreeToDelete: string): void
  • Recursively delete all files and subdirectories of the specified directory. Ensure that we do not follow a symlink. Just delete the link.

    params

    {string} pathToTreeToDelete - Path to top directory of the tree to delete.

    Parameters

    • pathToTreeToDelete: string

    Returns void

Static deleteFile

  • deleteFile(file: string): void

Static deleteSymLink

  • deleteSymLink(symLinkPath: string): void

Static existsSync

  • existsSync(file: string): boolean
  • Wraps fs.existsSync so that we dont have to import fs unnecessarily

    static
    memberof

    IO

    Parameters

    • file: string

      file to validate existence against

    Returns boolean

    true if file exists

Static getDefaultTextEditor

  • getDefaultTextEditor(): string

Static giveAccessOnlyToOwner

  • giveAccessOnlyToOwner(fileName: string): void
  • Set file access permissions so that only the current user will have access to the file. On windows, it means "full control" for the current user. On posix, it means read & write access for the current user. Obviously, the current user must have permission to change permissions on the specified file.

    throws

    An ImperativeError when the operation fails.

    Parameters

    • fileName: string

      file name for which we modify access.

    Returns void

Static isDir

  • isDir(dirOrFile: string): boolean
  • Return whether input file is a directory or file

    static
    memberof

    IO

    Parameters

    • dirOrFile: string

      file path

    Returns boolean

    • true if file path is a directory, false otherwise

Static mkdirp

  • mkdirp(dir: string): void
  • Uses the fs-extra package to create a directory (and all subdirectories)

    static
    memberof

    IO

    Parameters

    • dir: string

      the directory (do not include a file name)

    Returns void

Static normalizeExtension

  • normalizeExtension(extension: string): string
  • Take an extension and prefix with a '.' identifier

    static
    memberof

    IO

    Parameters

    • extension: string

      extension to normalize

    Returns string

    • '.bin' for input 'bin' for example

Static processNewlines

  • processNewlines(original: string, lastByte?: number): string
  • Process a string so that its line endings are operating system appropriate before you save it to disk (basically, if the user is on Windows, change \n to \r\n)

    static
    memberof

    IO

    Parameters

    • original: string

      original input

    • Optional lastByte: number

      last byte of previous input, if it is being processed in chunks

    Returns string

    • input with removed newlines

Static readFileSync

  • readFileSync(file: string, normalizeNewLines?: boolean, binary?: boolean): Buffer
  • Wraps fs.readFileSync so that we dont have to import fs unnecessarily or specify encoding.

    static
    memberof

    IO

    Parameters

    • file: string

      file to read

    • Default value normalizeNewLines: boolean = false

      remove Windows line endings (\r\n) in favor of \n

    • Default value binary: boolean = false

      should the file be read in binary mode? If so, normalizeNewLines is ignored. If false, the file will be read in UTF-8 encoding

    Returns Buffer

    Buffer - the content of the file

Static writeFile

  • writeFile(file: string, content: Buffer): void

Static writeFileAsync

  • writeFileAsync(file: string, content: string): Promise<void>

Static writeObject

  • writeObject(configFile: string, object: object): void
  • Write an object to a file and set consistent formatting on the serialized JSON object.

    static
    memberof

    IO

    Parameters

    • configFile: string

      file to create

    • object: object

      object to serialize

    Returns void

Generated using TypeDoc