Last active
August 7, 2018 13:01
-
-
Save afrontend/d350fe2254beaa67859418bcb1240282 to your computer and use it in GitHub Desktop.
로그 문자열에 라인 번호 넣는 스크립트, https://agvim.wordpress.com/2018/08/07/insert-line-number-into-log-message-with-javascript/
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
#!/usr/bin/env node | |
const cli = require('cli'); | |
let line_number = 0, re; | |
cli.withInput(function (line, newline, eof) { | |
line_number = line_number + 1; | |
re = new RegExp(process.argv[2]); | |
if (!eof) { | |
if(line.match(re)) { | |
this.output(line.replace(/\)\s*;\s*$/, ', "'+line_number+'");')); | |
} else { | |
this.output(line); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment