Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

bin.js 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/usr/bin/env node
  2. var rimraf = require('./')
  3. var help = false
  4. var dashdash = false
  5. var noglob = false
  6. var args = process.argv.slice(2).filter(function(arg) {
  7. if (dashdash)
  8. return !!arg
  9. else if (arg === '--')
  10. dashdash = true
  11. else if (arg === '--no-glob' || arg === '-G')
  12. noglob = true
  13. else if (arg === '--glob' || arg === '-g')
  14. noglob = false
  15. else if (arg.match(/^(-+|\/)(h(elp)?|\?)$/))
  16. help = true
  17. else
  18. return !!arg
  19. })
  20. if (help || args.length === 0) {
  21. // If they didn't ask for help, then this is not a "success"
  22. var log = help ? console.log : console.error
  23. log('Usage: rimraf <path> [<path> ...]')
  24. log('')
  25. log(' Deletes all files and folders at "path" recursively.')
  26. log('')
  27. log('Options:')
  28. log('')
  29. log(' -h, --help Display this usage info')
  30. log(' -G, --no-glob Do not expand glob patterns in arguments')
  31. log(' -g, --glob Expand glob patterns in arguments (default)')
  32. process.exit(help ? 0 : 1)
  33. } else
  34. go(0)
  35. function go (n) {
  36. if (n >= args.length)
  37. return
  38. var options = {}
  39. if (noglob)
  40. options = { glob: false }
  41. rimraf(args[n], options, function (er) {
  42. if (er)
  43. throw er
  44. go(n+1)
  45. })
  46. }