strip-ansi 700 B

123456789101112131415161718192021222324252627
  1. #!/usr/bin/env node
  2. 'use strict';
  3. var fs = require('fs');
  4. var strip = require('./index');
  5. var input = process.argv[2];
  6. if (process.argv.indexOf('-h') !== -1 || process.argv.indexOf('--help') !== -1) {
  7. console.log('strip-ansi <input file> > <output file>');
  8. console.log('or');
  9. console.log('cat <input file> | strip-ansi > <output file>');
  10. return;
  11. }
  12. if (process.argv.indexOf('-v') !== -1 || process.argv.indexOf('--version') !== -1) {
  13. console.log(require('./package').version);
  14. return;
  15. }
  16. if (input) {
  17. process.stdout.write(strip(fs.readFileSync(input, 'utf8')));
  18. return;
  19. }
  20. process.stdin.setEncoding('utf8');
  21. process.stdin.on('data', function (data) {
  22. process.stdout.write(strip(data));
  23. });