Last active
August 29, 2015 14:21
-
-
Save kawanet/ea442e5f03cb5cbaec3b to your computer and use it in GitHub Desktop.
node.js で、起動時のコマンドライン引数にある「-v」の個数を1行で取得
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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