delete expired file。
npm install del-expired-file --save
'use strict';
const path = require('path');
const delExpiredFile = require('del-expired-file');
const filesPath = path.resolve('./');
delExpiredFile({
filePath: filesPath,
ext: 'txt',
expiredType: 'ctime',
date: '5s',
})
.then((res) => {
console.log('delete file', res);
});
// ['a.txt', 'b.txt']
options
<Object>
filePath
<string>
: default ispwd
ext
<string>
expiredType
<string>
: [ctime
,atime
,mtime
], default isctime
date
string
: [3d
,5h
,6m
,30s
], default is3d