babel-plugin-annotate-console-log icon indicating copy to clipboard operation
babel-plugin-annotate-console-log copied to clipboard

add script path

Open laggingreflex opened this issue 9 years ago • 3 comments

If you specify option "scriptPath": true:

"plugins": [
  ["annotate-console-log", {
    "scriptPath": true
  }]
]

it'll add a short script path (and line number)

console.log('hi')
// =>
console.log('[file.js:3]', 'foo()', 'hi')

If the filename was index.js it'll ad the parent foldername

console.log('[foo/index.js:5]', 'foo()', 'hi')

Use "fullScriptPath": true to add more detailed script path info

console.log('foo()', 'hi', {
  scriptColumn: 4,
  scriptLine: 9,
  scriptPath: 'relative/to/nearest/package.json/full-script-path/index.js'
})

fixes #1

laggingreflex avatar Nov 29 '16 13:11 laggingreflex

@gajus thoughts on this? I was also thinking maybe having only this (the short script path) without the function name. What would you say about making the function name optional, like {functionName: false, scriptPath: true}

laggingreflex avatar Jan 02 '17 10:01 laggingreflex

Whats the reason for wanting to include the file name, line, column if this information is already present in the console?

screen shot 2017-01-02 at 13 18 05

As is "VM214:1" in this screenshot.

gajus avatar Jan 02 '17 11:01 gajus

I'm using this in Node

laggingreflex avatar Jan 02 '17 11:01 laggingreflex