Skip to content

Instantly share code, notes, and snippets.

@kawanet
Last active August 29, 2015 14:21
Show Gist options
  • Select an option

  • Save kawanet/ea442e5f03cb5cbaec3b to your computer and use it in GitHub Desktop.

Select an option

Save kawanet/ea442e5f03cb5cbaec3b to your computer and use it in GitHub Desktop.
node.js で、起動時のコマンドライン引数にある「-v」の個数を1行で取得
var VERBOSE = Array.prototype.filter.call(process.argv, RegExp.prototype.test.bind(RegExp("^-v$"))).length;
console.error("error");
if (VERBOSE > 0) console.warn("warn");
if (VERBOSE > 1) console.log("log");
if (VERBOSE > 2) console.info("info");
if (VERBOSE > 3) console.debug("debug");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment