Utility TypeScript @ 2.0.0-beta
    Preparing search index...

    Class NodeFiles

    A configurable class for working with files and paths in node.

    0.2.0

    Hierarchy (View Summary)

    Index

    Constructors

    Properties - Aliases

    Properties - Args

    Properties - Classes

    Accessors - Args

    Methods - Args

    Methods - Exporters

    Methods - Filers

    Methods - Meta

    Methods - Path-makers

    Constructors

    Properties - Aliases

    mergeArgs: {
        <D extends object>(
            defaults: D,
            inputs?: undefined,
            recursive?: boolean,
        ): D;
        <D extends object, I extends Partial<D>>(
            defaults: D,
            inputs: I,
            recursive?: false,
        ): D & I;
        <D extends object, I extends Partial<D> | RecursivePartial<D>>(
            defaults: D,
            inputs: I,
            recursive: true,
        ): D & I;
        <D extends object, I extends Partial<D> | RecursivePartial<D>>(
            defaults: D,
            inputs?: I,
            recursive?: boolean,
        ): D | D & I;
    } = mergeArgs

    An alias for this package's mergeArgs().

    Type declaration

      • <D extends object>(defaults: D, inputs?: undefined, recursive?: boolean): D
      • Inputs can be undefined, and if so, the default is returned.

        Type Parameters

        • D extends object

          Default object type.

        Parameters

        • defaults: D

          Default values (if not specified in inputs).

        • Optionalinputs: undefined

          Overriding values (changes to make).

        • Optionalrecursive: boolean

          Optional. Whether to merge the object recursively. Default false.

        Returns D

        Resulting object with all the defaults and inputs keys with either default values or input values, as appropriate.

      • <D extends object, I extends Partial<D>>(
            defaults: D,
            inputs: I,
            recursive?: false,
        ): D & I
      • Passing recursive as false means that the input type must be a Partial (not RecursivePartial).

        Type Parameters

        • D extends object
        • I extends Partial<D>

        Parameters

        • defaults: D
        • inputs: I
        • Optionalrecursive: false

        Returns D & I

      • <D extends object, I extends Partial<D> | RecursivePartial<D>>(
            defaults: D,
            inputs: I,
            recursive: true,
        ): D & I
      • Passing recursive as true means that the input type may actually be a RecursivePartial.

        Type Parameters

        Parameters

        • defaults: D
        • inputs: I
        • recursive: true

        Returns D & I

      • <D extends object, I extends Partial<D> | RecursivePartial<D>>(
            defaults: D,
            inputs?: I,
            recursive?: boolean,
        ): D | D & I
      • Universal overload.

        Type Parameters

        Parameters

        • defaults: D
        • Optionalinputs: I
        • Optionalrecursive: boolean

        Returns D | D & I

    Properties - Args

    A completed args object.

    Properties - Classes

    The instance of NodeConsole used within this class.

    Accessors - Args

    • get ARGS_DEFAULT(): {
          argsRecursive: true;
          copyFile: { force: true; recursive: false; rename: true };
          readDir: { recursive: false };
          readFile: {};
          root: "./";
          write: { force: boolean; rename: boolean };
      }

      Default args for this stage.

      Returns {
          argsRecursive: true;
          copyFile: { force: true; recursive: false; rename: true };
          readDir: { recursive: false };
          readFile: {};
          root: "./";
          write: { force: boolean; rename: boolean };
      }

    Methods - Args

    Methods - Exporters

    Methods - Filers

    • Experimental

      Copies a file to another path.

      Parameters

      • source: string

        Location to write file.

      • destination: string

        Location to copy the source path to.

      • args: Partial<CopyFileArgs> = {}

        Optional configuration.

      Returns string | false

      Path to file if written, or false on failure.

      2.0.0-alpha

      2.0.0-alpha.1 — Now checks that the file exists first. If so, returns ''.

    • Deletes given files.

      Parameters

      • paths: string[]

        Paths to delete. Absolute or relative to root dir.

      • logLevel: number = 0

        Base depth for console messages (via NodeConsole).

      • dryRun: boolean = false

        If true, files that would be deleted are printed to the console and not deleted.

      Returns void

      2.0.0-alpha — Renamed to delete from deleteFiles.

    • Experimental

      Creates a directory.

      Parameters

      • path: string

      Returns undefined | string

      2.0.0-alpha

      2.0.0-alpha.1 — Removed args param and now forces recursion.

    • Experimental

      Read the paths within a directory.

      Parameters

      Returns string[]

      Paths within the given directory.

      2.0.0-alpha

      2.0.0-alpha.1 — Now checks that the file exists first. If so, returns ''.

    • Writes a file.

      Parameters

      • path: string

        Location to write file.

      • content: string | string[]

        Contents to write.

      • args: Partial<WriteFileArgs> = {}

        Optional configuration.

      Returns string | false

      Path to file if written, or false on failure.

      2.0.0-alpha — Renamed to write from writeFiles.

    Methods - Meta

    • Experimental

      Gets the NodeFS.Stats value for the given path.

      Parameters

      • path: string

      Returns undefined | Stats

      2.0.0-alpha

    Methods - Path-makers

    • Experimental

      Gets the basename of the given path.

      Parameters

      • path: string
      • Optionalsuffix: string | false

      Returns string

      2.0.0-alpha

    • Changes just the file name of a path

      Parameters

      • path: string
      • newName: string

      Returns string

      Full path with updated basename.

    • Experimental

      Checks whether a file, directory, or link exists at the given path.

      Parameters

      • path: string

      Returns boolean

      2.0.0-alpha

    • Experimental

      Checks if the given path is a directory.

      Parameters

      • path: string

      Returns boolean

      2.0.0-alpha

    • Experimental

      Checks if the given path is a file.

      Parameters

      • path: string

      Returns boolean

      2.0.0-alpha

    • Experimental

      Checks if the given path is a symbolic link.

      Parameters

      • path: string

      Returns boolean

      2.0.0-alpha

    • Returns relative paths, based on the root defined the the opts.

      Parameters

      • path: string

        Path to make relative.

      Returns string

    • Resolves relative to the root defined the the opts.

      Parameters

      • ...paths: string[]

        Paths to resolve.

      Returns string

    • Returns a unique version of the inputPath (i.e., where no file exists) by appending a number.

      Parameters

      • inputPath: string

        Path to make unique.

      Returns string

      Absolute, unique version of the given inputPath.

      NodeFiles.changeBaseName Used to update the basename to test for uniqueness.