Skip to content

Commit

Permalink
Use async function for bin
Browse files Browse the repository at this point in the history
The better to handle win32's EBUSY.

Fix #74
  • Loading branch information
isaacs committed Jun 30, 2015
1 parent 2128f0b commit ece14b6
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,23 @@ var args = process.argv.slice(2).filter(function(arg) {
if (help || args.length === 0) {
// If they didn't ask for help, then this is not a "success"
var log = help ? console.log : console.error
log('Usage: rimraf <path>')
log('Usage: rimraf <path> [<path> ...]')
log('')
log(' Deletes all files and folders at "path" recursively.')
log('')
log('Options:')
log('')
log(' -h, --help Display this usage info')
process.exit(help ? 0 : 1)
} else {
args.forEach(function(arg) {
rimraf.sync(arg)
} else
go(0)

function go (n) {
if (n >= args.length)
return
rimraf(args[n], function (er) {
if (er)
throw er
go(n+1)
})
}

0 comments on commit ece14b6

Please sign in to comment.