0.0.3 • Published 3 years ago

regex-unlink v0.0.3

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

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 glob

  • unlink: function unlink(path: string, callback?: Function): void; unlink using callback, equivalent of fs.unlink

  • asyncUnlink: function asyncUnlink(path: string): Promise<void>; unlink using Promise, equivalent of fs.promises.unlink

License

regex-unlink using the MIT License

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago