Skip to content

A Node JS library that delete all empty files and folders in a target directory.

License

Notifications You must be signed in to change notification settings

noahweasley/Clean-Sweep

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Clean Sweep

license GitHub tag (with filter) npm downloads

Delete all empty files and folders in a target directory.

How to Use

Installation (as a script)

npm install clean-sweep -g

Usage (as a script)

clean-sweep <path/to/directory> -v
# OR
csw <path/to/directory> -v
  • The first argument is the path to the directory in which the operation would be performed, and is required!
  • The remaining are optional, -v parameter prints out the operation of the sweep function to console if specifies

Example

clean-sweep ./music
clean-sweep ./music -v
# OR
csw ./music
csw ./music -v

Installation (in code)

npm install clean-sweep --save

Usage (in code, synchronously)

const cleanSweep = require("clean-sweep");
const fileDirectory = "<replace file directory here>";

try {
  cleanSweep.sweepSync(fileDirectory, { verbose: true });
} catch (err) {
  if (err.code == "ENOENT") {
    console.error("Directory does not exist");
  } else {
    console.error(err.message);
  }
}

Usage (in code, asynchronously)

const cleanSweep = require("clean-sweep").promises;
const fileDirectory = "./";

(async function () {
  try {
    await cleanSweep.sweep(fileDirectory, { verbose: true });
  } catch (err) {
    if (err.code == "ENOENT") {
      console.error("Directory does not exist");
    } else {
      console.error(err.message);
    }
  }
})();