NPM Build Utilities @ 0.1.3
    Preparing search index...

    Class FileSystem

    Extends the node.NodeFiles class with some custom logic useful to this package.

    0.1.0-alpha

    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

    A completed args object.

    • get ARGS_DEFAULT(): {
          argsRecursive: true;
          copy: {
              force: true;
              glob: { absolute: false; dot: true; filesOnly: false };
              recursive: true;
              rename: true;
          };
          copyFile: { force: true; recursive: false; rename: true };
          glob: {
              absolute: true;
              dot: true;
              ignore: [
                  "._*",
                  "._*/**",
                  "**/._*",
                  "**/._*/**",
                  "**/.DS_Store",
                  "**/.smbdelete**",
              ];
          };
          minify: { css: {}; glob: {}; html: {}; js: {}; json: {} };
          prettier: {
              _: {
                  bracketSameLine: false;
                  bracketSpacing: true;
                  experimentalOperatorPosition: "start";
                  experimentalTernaries: false;
                  glob: {};
                  htmlWhitespaceSensitivity: "strict";
                  jsxSingleQuote: false;
                  printWidth: 80;
                  proseWrap: "preserve";
                  semi: true;
                  singleAttributePerLine: true;
                  singleQuote: true;
                  tabWidth: 4;
                  trailingComma: "all";
                  useTabs: false;
              };
              css: { singleQuote: false };
              html: { printWidth: 10000 };
          };
          readDir: { recursive: false };
          readFile: {};
          root: "./";
          write: { force: boolean; rename: boolean };
      }

      Default args for this stage.

      Returns {
          argsRecursive: true;
          copy: {
              force: true;
              glob: { absolute: false; dot: true; filesOnly: false };
              recursive: true;
              rename: true;
          };
          copyFile: { force: true; recursive: false; rename: true };
          glob: {
              absolute: true;
              dot: true;
              ignore: [
                  "._*",
                  "._*/**",
                  "**/._*",
                  "**/._*/**",
                  "**/.DS_Store",
                  "**/.smbdelete**",
              ];
          };
          minify: { css: {}; glob: {}; html: {}; js: {}; json: {} };
          prettier: {
              _: {
                  bracketSameLine: false;
                  bracketSpacing: true;
                  experimentalOperatorPosition: "start";
                  experimentalTernaries: false;
                  glob: {};
                  htmlWhitespaceSensitivity: "strict";
                  jsxSingleQuote: false;
                  printWidth: 80;
                  proseWrap: "preserve";
                  semi: true;
                  singleAttributePerLine: true;
                  singleQuote: true;
                  tabWidth: 4;
                  trailingComma: "all";
                  useTabs: false;
              };
              css: { singleQuote: false };
              html: { printWidth: 10000 };
          };
          readDir: { recursive: false };
          readFile: {};
          root: "./";
          write: { force: boolean; rename: boolean };
      }

    Classes

    console: Logger

    Instance used to log messages within the class.

    The instance of NodeConsole used within this class.

    Constructor

    Exporters

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

      Returns string

    Filers

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

      FileSystem.Error — If copying a file fails.

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

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

      This catches any errors from node.NodeFiles.delete, ignores ENOTEMPTY errors, and re-throws the rest.

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

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

    • 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

    • 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

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

    Transformers

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