Options
All
  • Public
  • Public/Protected
  • All
Menu

Directory manager that creates temporary directories in the system temporary directory. It cleans them up after two hours or on program exit, if possible. The class only creates a single instance of itself.

It uses tmp-promise (built on tmp) to create clean temporary directories to work with git projects from remotes

Hierarchy

  • CleaningTmpDirectoryManager

Implements

Index

Constructors

constructor

Properties

Private initialized

initialized: boolean = false

Private Readonly instance

instance: this

Private Readonly maxAge

maxAge: number = 1000 * 60 * 60 * 2

Readonly prefix

prefix: string = `atm-${process.pid}-`

Private Readonly reapInterval

reapInterval: number = 1000 * 60 * 30

Readonly root

root: string = os.tmpdir()

Methods

ageFilter

  • ageFilter(old?: number, now?: number): (d: string) => boolean
  • Filter directory on age. The returned function returns true if the age of its argument, as determined by the stat mtime, is greater than the old, which defaults to 2 hours.

    Parameters

    • Default value old: number = this.maxAge

      Age beyond which true will be returned

    • Optional now: number

      Time to consider the current time, defaults to Date.now()

    Returns (d: string) => boolean

      • (d: string): boolean
      • Parameters

        • d: string

        Returns boolean

Private cleanup

  • cleanup(p: string, keep: boolean): Promise<void>

directoryFor

Private initialize

  • initialize(): this

noFilter

  • noFilter(d: string): boolean

reap

  • reap(filter?: (d: string) => boolean): Promise<number>
  • Remove temporary directories created by this object that pass the filter. All operations of this method are wrapped in a try/catch block to make it safe for use in timers and intervals, although the return value will be ignored in those cases.

    Parameters

    • Default value filter: (d: string) => boolean = this.noFilter

      If this returns true when passed the basename of the temporary directory, the directory will be deleted

        • (d: string): boolean
        • Parameters

          • d: string

          Returns boolean

    Returns Promise<number>

    0 if succesful, 1 otherwise

Generated using TypeDoc