diff --git a/index.js b/index.js old mode 100644 new mode 100755 index 48be582..1b5d069 --- a/index.js +++ b/index.js @@ -1,3 +1,5 @@ +#!/usr/bin/env node + /* color */"use strict" @@ -133,4 +135,18 @@ color.matches = function(string){ return !!(string + "").match(regexp) } +var firstArg = function(fn, context) { + return function() { + var args = Array.prototype.slice.call(arguments); + return fn.call(context, args.length ? args[0] : null); + }; +} + +// http://nodejs.org/api/modules.html#modules_accessing_the_main_module +if (require.main === module) { + process.argv.slice(2) + .map(firstArg(color)) + .forEach(firstArg(console.log, console)); +} + module.exports = color