Created
January 23, 2013 14:05
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You inspired me, too