class method FsTools.remove

View source on GitHub →

FsTools.remove(path, callback) → void
  • path (String) – Path to remove
  • callback (Function) – Fired after path was removed

Removes given path. If it was a directory will remove it recursively, similar to UNIX' rm -rf <path>. After all will fire callback(err) with an error if there were any.

If given path was file - will proxy call to fs.unlink.

Example
fstools.remove('/home/nodeca/trash', function (err) {
  if (err) {
    console.log("U can't touch that");
    console.err(err);
    process.exit(1);
  } else {
    console.log("It's Hammer time");
    process.exit(0);
  }
});