Skip to content

Commit 736887a

Browse files
committed
const/let and arrow functions in bin script
1 parent d7e41a2 commit 736887a

File tree

1 file changed

+17
-19
lines changed

1 file changed

+17
-19
lines changed

bin.js

+17-19
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#!/usr/bin/env node
22

3-
var rimraf = require('./')
3+
const rimraf = require('./')
44

5-
var help = false
6-
var dashdash = false
7-
var noglob = false
8-
var args = process.argv.slice(2).filter(function(arg) {
5+
let help = false
6+
let dashdash = false
7+
let noglob = false
8+
const args = process.argv.slice(2).filter(arg => {
99
if (dashdash)
1010
return !!arg
1111
else if (arg === '--')
@@ -20,9 +20,20 @@ var args = process.argv.slice(2).filter(function(arg) {
2020
return !!arg
2121
})
2222

23+
const go = n => {
24+
if (n >= args.length)
25+
return
26+
const options = noglob ? { glob: false } : {}
27+
rimraf(args[n], options, er => {
28+
if (er)
29+
throw er
30+
go(n+1)
31+
})
32+
}
33+
2334
if (help || args.length === 0) {
2435
// If they didn't ask for help, then this is not a "success"
25-
var log = help ? console.log : console.error
36+
const log = help ? console.log : console.error
2637
log('Usage: rimraf <path> [<path> ...]')
2738
log('')
2839
log(' Deletes all files and folders at "path" recursively.')
@@ -35,16 +46,3 @@ if (help || args.length === 0) {
3546
process.exit(help ? 0 : 1)
3647
} else
3748
go(0)
38-
39-
function go (n) {
40-
if (n >= args.length)
41-
return
42-
var options = {}
43-
if (noglob)
44-
options = { glob: false }
45-
rimraf(args[n], options, function (er) {
46-
if (er)
47-
throw er
48-
go(n+1)
49-
})
50-
}

0 commit comments

Comments
 (0)