Comparing version 1.0.1 to 1.0.2
var fs = require('fs') | ||
var rmrf = module.exports = function(dirPath) { | ||
var files | ||
try { files = fs.readdirSync(dirPath) } catch(e) {} | ||
if (files) { | ||
if (files.length > 0) | ||
if (fs.existsSync(dirPath)) { | ||
var files = fs.readdirSync(dirPath) | ||
if (files && files.length > 0) { | ||
for (var i = 0; i < files.length; i++) { | ||
@@ -15,4 +14,5 @@ var filePath = dirPath + '/' + files[i] | ||
} | ||
} | ||
fs.rmdirSync(dirPath) | ||
} | ||
} |
{ | ||
"name": "rmrf", | ||
"version": "1.0.1", | ||
"description": "slim and synchronous `rm -rf` for node", | ||
"version": "1.0.2", | ||
"description": "No BS synchronous `rm -rf` for node.js", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"test": "mocha test index.js" | ||
}, | ||
@@ -9,0 +9,0 @@ "repository": { |
node-rmrf | ||
========= | ||
slim and synchronous `rm -rf` for node | ||
No BS synchronous `rm -rf` for [node.js](http://nodejs.org/). |
@@ -6,8 +6,8 @@ var rmrf = require('../index.js') | ||
before(function(){ | ||
try { fs.readdirSync(__dirname + '/exists') } catch(e){ | ||
fs.mkdirSync(__dirname + '/exists') | ||
fs.mkdirSync(__dirname + '/exists/nested') | ||
} | ||
}) | ||
// not bothering with 'before' as it was unreliable | ||
if (!fs.existsSync(__dirname + '/exists')) { | ||
fs.mkdirSync(__dirname + '/exists') | ||
fs.mkdirSync(__dirname + '/exists/nested') | ||
fs.openSync( __dirname + '/exists/nested/empty.txt', 'w') | ||
} | ||
@@ -14,0 +14,0 @@ describe('rmrf', function(){ |
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
3024
1