1.1.4 • Published 3 years ago

lex-files-rotate v1.1.4

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

This module rotates files inside a folder according to various parameters

Methods

const Rotate = require('lex-files-rotate')

const rotate = new Rotate({...})

rotate.start() // Start process
rotate.stop() // Stop process

Parameters

  • type: String, required. The type of process. Can only be file or dir
  • path: String, required. Absolute path to the file or directory
  • interval: v1.1.3+ Number, default 30000(dir)/10000(file). The frequency of scanning a directory or file (milliseconds).

// Only for the dir type

  • maxFiles: Number. Maximum number of files that can be located in a directory
  • ignoreFiles: Array of String. Name of the files that will not be deleted
  • maskFiles: Array of String. The string that should be in the file name. Only the files containing the string will be deleted

// Only for the file type

  • maxSize: Number. Maximum file size in KB

Examples

This code will only leave 10 files inside the specified directory

const Rotate = require('lex-files-rotate')

const rotate = new Rotate({
    type: 'dir',
    path: 'path to directory',
    maxFiles: 10
})

rotate.start()

This code will keep track of the file size and divide it into several parts

const Rotate = require('lex-files-rotate')

const rotate = new Rotate({
    type: 'file',
    path: 'path to file',
    maxSize: 5  // KB
})

rotate.start()

This code will monitor the number of files in the directory and the size of a particular file

const Rotate = require('lex-files-rotate')

const dirRotate = new Rotate({
    type: 'dir',
    path: '/dirname',
    maxFiles: 10,
    maskFiles: ['_big.txt'] // Delete only those files that match the mask
})
const fileRotate = new Rotate({
    type: 'file',
    path: '/dirname/big.txt',
    maxSize: 5  // KB
})

dirRotate.start()
fileRotate.start()
1.1.1

3 years ago

1.1.0

3 years ago

1.1.4

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago