mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-02-20 22:23:53 +08:00
fix(deprecate-utils): Add location where deprecation warning was issued
- Resolves #1599
This commit is contained in:
parent
c6acca8ca3
commit
801325bb38
1 changed files with 12 additions and 1 deletions
|
@ -1,6 +1,16 @@
|
|||
_ = require 'underscore'
|
||||
|
||||
class DeprecateUtils
|
||||
# See
|
||||
# http://www.codeovertones.com/2011/08/how-to-print-stack-trace-anywhere-in.html
|
||||
@parseStack: (stackString) ->
|
||||
stack = stackString
|
||||
.replace(/^[^\(]+?[\n$]/gm, '')
|
||||
.replace(/^\s+at\s+/gm, '')
|
||||
.replace(/^Object.<anonymous>\s*\(/gm, '{anonymous}()@')
|
||||
.split('\n')
|
||||
return stack
|
||||
|
||||
@warn: (condition, message) ->
|
||||
console.warn message if condition
|
||||
|
||||
|
@ -8,10 +18,11 @@ class DeprecateUtils
|
|||
if NylasEnv.inDevMode() and not NylasEnv.inSpecMode()
|
||||
warn = true
|
||||
newFn = =>
|
||||
stack = DeprecateUtils.parseStack((new Error()).stack)
|
||||
DeprecateUtils.warn(
|
||||
warn,
|
||||
"Deprecation warning! #{fnName} is deprecated and will be removed soon.
|
||||
Use #{newName} instead."
|
||||
Use #{newName} instead.\nCheck your code at #{stack[1]}"
|
||||
)
|
||||
warn = false
|
||||
return fn.apply(ctx, arguments)
|
||||
|
|
Loading…
Reference in a new issue