regex-unlink
TypeScript icon, indicating that this package has built-in type declarations

0.0.3 • Public • Published

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

/regex-unlink/

    Package Sidebar

    Install

    npm i regex-unlink

    Weekly Downloads

    11

    Version

    0.0.3

    License

    MIT

    Unpacked Size

    6.86 kB

    Total Files

    9

    Last publish

    Collaborators

    • developerfauzan