bin.js 620 B

1234567891011121314151617181920212223242526272829
  1. #!/usr/bin/env node
  2. var concat = require('simple-concat')
  3. var undeclared = require('./')
  4. if (arg('--help') || arg('-h')) {
  5. console.log('usage: undeclared-identifiers [--identifiers] [--properties] < source.js')
  6. process.exit(0)
  7. }
  8. concat(process.stdin, function (err, src) {
  9. if (err) throw err
  10. var r = undeclared(src)
  11. var i = arg('--identifiers') || arg('-i')
  12. var p = arg('--properties') || arg('-p')
  13. if (!i && !p) i = p = true
  14. if (i) r.identifiers.forEach(log)
  15. if (p) r.properties.forEach(log)
  16. })
  17. function arg (s) {
  18. return process.argv.indexOf(s) !== -1
  19. }
  20. function log (n) {
  21. console.log(n)
  22. }