regex-unlink
v0.0.3
Published
fs.unlink but accepts regex.
Downloads
3
Maintainers
Readme
regex-unlink
fs.unlink
but accepts regex, works with Promise
and callback
approach.
Why accepts regex? simply glob
core using minimatch
that use regex.
Installation
npm install regex-unlink
Usage
The usage was so simple and similar with fs.unlink
.
// delete files with `.txt` extension using callback approach
unlink("**/**.txt", (err) => {
if (err) {
console.log(err);
return;
}
console.log("Delete all .txt files successful!");
});
// you can specify path without regex
unlink("./text.txt", (err) => {
if (err) {
console.log(err);
return;
}
console.log("Delete all .txt files successful!");
});
// delete files with `.txt` extension using asynchronous approach
(async () => {
await asyncUnlink("**/**.txt", (err) => {
if (err) {
console.log(err);
}
console.log("Delete all .txt files successful!");
});
})();
API
examples here.
declaration files here.
options:
const options: globOptions;
options binding for globunlink:
function unlink(path: string, callback?: Function): void;
unlink usingcallback
, equivalent offs.unlink
asyncUnlink:
function asyncUnlink(path: string): Promise<void>;
unlink usingPromise
, equivalent offs.promises.unlink
License
regex-unlink
using the MIT License