NPM Build Utilities @ 0.1.3
    Preparing search index...

    Interface FileSystemTypeInternal

    Shape of the file/path utility class.

    Defined here so that the type can easily be used before the FileSystem class is defined.

    0.1.0-alpha

    interface FileSystemType {
        args: Args;
        console: Logger;
        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;
        };
        nc: NodeConsole;
        get ARGS_DEFAULT(): {
            argsRecursive: true;
            copyFile: { force: true; recursive: false; rename: true };
            readDir: { recursive: false };
            readFile: {};
            root: "./";
            write: { force: boolean; rename: boolean };
        };
        basename(path: string, suffix?: string | false): string;
        buildArgs(args?: Partial<Args> | RecursivePartial<Args>): Args;
        changeBaseName(path: string, newName: string): string;
        copy(
            globs: string | string[],
            level: number,
            outputDir: string,
            sourceDir?: null | string,
            args?: Partial<FileSystemType.Copy.Args>,
        ): string[];
        copyFile(
            source: string,
            destination: string,
            args?: Partial<CopyFileArgs>,
        ): string | false;
        delete(
            globs: string | string[],
            level: number,
            dryRun?: boolean,
            args?: Partial<FileSystemType.Glob.Args>,
        ): void;
        dirname(path: string): string;
        exists(path: string): boolean;
        getStats(path: string): undefined | Stats;
        glob(
            globs: string | string[],
            args?: Partial<FileSystemType.Glob.Args>,
        ): string[];
        isDirectory(path: string): boolean;
        isFile(path: string): boolean;
        isSymLink(path: string): boolean;
        minify(
            globs: string | string[],
            format: FileSystemType.Minify.Format,
            level: number,
            args?: Partial<FileSystemType.Minify.Args>,
            renamer?: (path: string) => string,
        ): Promise<{ output: string; source: string }[]>;
        mkdir(path: string): undefined | string;
        pathRelative(path: string): string;
        pathResolve(...paths: string[]): string;
        prettier(
            globs: string | string[],
            format: FileSystemType.Prettier.Format,
            args?: Partial<FileSystemType.Prettier.Args>,
        ): Promise<string[]>;
        readDir(path: string, args?: Partial<ReadDirArgs>): string[];
        readFile(path: string, args?: Partial<ReadFileArgs>): string;
        replaceInFiles(
            globs: string | string[],
            replace: [string | RegExp, string] | [string | RegExp, string][],
            level: number,
            args?: Partial<FileSystemType.Glob.Args>,
        ): string[];
        toString(): string;
        uniquePath(inputPath: string): string;
        write(
            path: string,
            content: string | string[],
            args?: Partial<WriteFileArgs>,
        ): string | false;
    }

    Hierarchy

    Index

    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;
    }

    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

    Args

    args: Args

    A completed args object.

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

      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 };
      }

    Classes

    console: Logger

    Used to output messages within the class.

    The instance of NodeConsole used within this class.

    Exporters

    • Internal

      Overrides the default function to return a string representation of this object.

      Returns string

    Filers

    • Internal

      Copies files from one directory to another, maintaing their relative directory structure.

      Parameters

      • globs: string | string[]

        Glob patterns for paths to copy.

      • level: number

        Depth level for output to the console.

      • outputDir: string

        Path to directory where matched files will be copied.

      • OptionalsourceDir: null | string

        Relative source directory. If any, the globs are resolved as relative to that directory and the path/dir structure copied to the outputDir is relative to this sourceDir.

      • Optionalargs: Partial<FileSystemType.Copy.Args>

        Overrides for default options.

      Returns string[]

      Array of paths to the newly-copied files/etc.

      node.NodeFiles.copyFile Used to copy the matched paths.

    • Experimental

      Copies a file to another path.

      Parameters

      • source: string

        Location to write file.

      • destination: string

        Location to copy the source path to.

      • Optionalargs: 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 ''.

    • Internal

      Deletes given globs (via node.NodeFiles.delete).

      Parameters

      • globs: string | string[]

        Glob patterns for paths to delete.

      • level: number

        Depth level for output to the console.

      • OptionaldryRun: boolean

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

      • Optionalargs: Partial<FileSystemType.Glob.Args>

        Optional glob configuration.

      Returns void

    • 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 ''.

    • Internal

      Reads a file.

      Parameters

      Returns string

      Contents of the file.

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

    • Internal

      Writes a file.

      Parameters

      • path: string

        Location to write file.

      • content: string | string[]

        Contents to write.

      • Optionalargs: 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.

    Meta

    • Experimental

      Gets the NodeFS.Stats value for the given path.

      Parameters

      • path: string

      Returns undefined | Stats

      2.0.0-alpha

    Path-makers

    • Experimental

      Gets the basename of the given path.

      Parameters

      • path: string
      • Optionalsuffix: string | false

      Returns string

      2.0.0-alpha

    • Internal

      Changes just the file name of a path

      Parameters

      • path: string
      • newName: string

      Returns string

      Full path with updated basename.

    • Experimental

      Gets the path dirname via node:fs.dirname.

      Parameters

      • path: string

      Returns string

      2.0.0-alpha

    • 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

    • Internal

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

      Parameters

      • path: string

        Path to make relative.

      Returns string

    • Internal

      Resolves relative to the root defined the the opts.

      Parameters

      • ...paths: string[]

        Paths to resolve.

      Returns string

    • Internal

      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.

    Transformers

    • Internal

      Runs minify on the given file globs.

      Parameters

      • globs: string | string[]

        Glob patterns for paths to minify.

      • format: FileSystemType.Minify.Format

        File format for the input globs.

      • level: number

        Depth level for output to the console.

      • Optionalargs: Partial<FileSystemType.Minify.Args>

        Overrides for default options.

      • Optionalrenamer: (path: string) => string

        Function used to define the new basename for the minified files, if any.

      Returns Promise<{ output: string; source: string }[]>

      Paths to the minified files (both source and output).

    • Internal

      Replaces the given text or regex in the given file globs.

      Parameters

      • globs: string | string[]

        Glob patterns for paths to replace in.

      • replace: [string | RegExp, string] | [string | RegExp, string][]

        Replacements to make. The first tuple item is a string or RegExp to find and the second item is a string to replace.

      • level: number

        Depth level for output to the console.

      • Optionalargs: Partial<FileSystemType.Glob.Args>

        Optional glob configuration.

      Returns string[]

      Paths to the replaced files.