Created
November 28, 2016 17:46
-
-
Save stdavis/d7b7e9b949a6566efbacbd7c6ef022bb to your computer and use it in GitHub Desktop.
object function console log
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
| atom.commands.add('atom-text-editor', 'custom:conlog', function () { | |
| editor = atom.workspace.getActiveTextEditor(); | |
| const modName = editor.getTitle().split('.')[0]; | |
| const folder = path.basename(path.dirname(editor.getPath())); | |
| const currentPoint = editor.getCursorBufferPosition(); | |
| let funcName; | |
| editor.scan(/(\S*): function?\s\([\s\S]+?console.*/g, function (iterator) { | |
| if (iterator.range.containsPoint(currentPoint)) { | |
| console.log('found'); | |
| funcName = iterator.match[1]; | |
| iterator.stop(); | |
| } | |
| }); | |
| const txt = `console.log('${folder}/${modName}:${funcName}', arguments);`; | |
| const checkpoint = editor.createCheckpoint(); | |
| editor.setTextInBufferRange(editor.getCurrentParagraphBufferRange(), txt); | |
| editor.autoIndentSelectedRows(); | |
| editor.groupChangesSinceCheckpoint(checkpoint); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment