Skip to content

Instantly share code, notes, and snippets.

@royswale
Forked from geedew/node-rm-rf.js
Created February 3, 2021 12:36
Show Gist options
  • Select an option

  • Save royswale/e34deb837cb15ced51c71f5cbe7ed9dc to your computer and use it in GitHub Desktop.

Select an option

Save royswale/e34deb837cb15ced51c71f5cbe7ed9dc to your computer and use it in GitHub Desktop.

Revisions

  1. @geedew geedew renamed this gist Feb 11, 2015. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. @geedew geedew revised this gist Jan 25, 2015. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions node-rm-rf
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,4 @@
    var fs = require('fs');
    var deleteFolderRecursive = function(path) {
    if( fs.existsSync(path) ) {
    fs.readdirSync(path).forEach(function(file,index){
  3. @geedew geedew created this gist Jan 17, 2015.
    13 changes: 13 additions & 0 deletions node-rm-rf
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    var deleteFolderRecursive = function(path) {
    if( fs.existsSync(path) ) {
    fs.readdirSync(path).forEach(function(file,index){
    var curPath = path + "/" + file;
    if(fs.lstatSync(curPath).isDirectory()) { // recurse
    deleteFolderRecursive(curPath);
    } else { // delete file
    fs.unlinkSync(curPath);
    }
    });
    fs.rmdirSync(path);
    }
    };