Нет описания

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #!/usr/bin/env node
  2. 'use strict';
  3. var fs = require('fs');
  4. var strip = require('./strip-json-comments');
  5. var input = process.argv[2];
  6. function getStdin(cb) {
  7. var ret = '';
  8. process.stdin.setEncoding('utf8');
  9. process.stdin.on('data', function (data) {
  10. ret += data;
  11. });
  12. process.stdin.on('end', function () {
  13. cb(ret);
  14. });
  15. }
  16. if (process.argv.indexOf('-h') !== -1 || process.argv.indexOf('--help') !== -1) {
  17. console.log('strip-json-comments input-file > output-file');
  18. console.log('or');
  19. console.log('strip-json-comments < input-file > output-file');
  20. return;
  21. }
  22. if (process.argv.indexOf('-v') !== -1 || process.argv.indexOf('--version') !== -1) {
  23. console.log(require('./package').version);
  24. return;
  25. }
  26. if (input) {
  27. process.stdout.write(strip(fs.readFileSync(input, 'utf8')));
  28. return;
  29. }
  30. getStdin(function (data) {
  31. process.stdout.write(strip(data));
  32. });