mirror of
https://github.com/fooflington/selfdefined.git
synced 2025-11-01 22:48:33 +00:00
28 lines
700 B
JavaScript
Executable File
28 lines
700 B
JavaScript
Executable File
#!/usr/bin/env node
|
|
'use strict';
|
|
var fs = require('fs');
|
|
var strip = require('./index');
|
|
var input = process.argv[2];
|
|
|
|
if (process.argv.indexOf('-h') !== -1 || process.argv.indexOf('--help') !== -1) {
|
|
console.log('strip-ansi <input file> > <output file>');
|
|
console.log('or');
|
|
console.log('cat <input file> | strip-ansi > <output file>');
|
|
return;
|
|
}
|
|
|
|
if (process.argv.indexOf('-v') !== -1 || process.argv.indexOf('--version') !== -1) {
|
|
console.log(require('./package').version);
|
|
return;
|
|
}
|
|
|
|
if (input) {
|
|
process.stdout.write(strip(fs.readFileSync(input, 'utf8')));
|
|
return;
|
|
}
|
|
|
|
process.stdin.setEncoding('utf8');
|
|
process.stdin.on('data', function (data) {
|
|
process.stdout.write(strip(data));
|
|
});
|