diff options
Diffstat (limited to 'node_modules/gulp-util/node_modules/has-ansi/cli.js')
-rwxr-xr-x | node_modules/gulp-util/node_modules/has-ansi/cli.js | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/node_modules/gulp-util/node_modules/has-ansi/cli.js b/node_modules/gulp-util/node_modules/has-ansi/cli.js new file mode 100755 index 000000000..e0956fcc7 --- /dev/null +++ b/node_modules/gulp-util/node_modules/has-ansi/cli.js @@ -0,0 +1,53 @@ +#!/usr/bin/env node +'use strict'; +var pkg = require('./package.json'); +var hasAnsi = require('./'); +var input = process.argv[2]; + +function stdin(cb) { + var ret = ''; + process.stdin.setEncoding('utf8'); + process.stdin.on('data', function (data) { + ret += data; + }); + process.stdin.on('end', function () { + cb(ret); + }); +} + +function help() { + console.log([ + pkg.description, + '', + 'Usage', + ' $ has-ansi <string>', + ' $ echo <string> | has-ansi', + '', + 'Exits with code 0 if input has ANSI escape codes and 1 if not' + ].join('\n')); +} + +function init(data) { + process.exit(hasAnsi(data) ? 0 : 1); +} + +if (process.argv.indexOf('--help') !== -1) { + help(); + return; +} + +if (process.argv.indexOf('--version') !== -1) { + console.log(pkg.version); + return; +} + +if (process.stdin.isTTY) { + if (!input) { + help(); + return; + } + + init(input); +} else { + stdin(init); +} |