Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@skovalyov
Created January 23, 2013 14:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skovalyov/4605986 to your computer and use it in GitHub Desktop.
Save skovalyov/4605986 to your computer and use it in GitHub Desktop.
Recursive sync rmdir based on JavaScript implementation from https://gist.github.com/2367067
fs = require "fs"
path = require "path"
rmdir = (dir) ->
list = fs.readdirSync dir
for item in list
filename = path.join dir, item
stat = fs.statSync filename
if filename in [".", ".."]
# Skip
else if stat.isDirectory()
# Remove directory recursively
rmdir filename
else
# Remove file
fs.unlinkSync filename
fs.rmdirSync dir
module.exports = rmdir
@dead-claudia
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment