mirror of
https://github.com/atom/atom.git
synced 2026-01-22 21:38:10 -05:00
Craft manual deprecation to get around stack depth limit
This allows the deprecation to be properly associated with the package it originates from.
This commit is contained in:
@@ -140,19 +140,25 @@ loadFile = (module, filePath) ->
|
||||
if sourceCode.startsWith('"use babel"') or sourceCode.startsWith("'use babel'")
|
||||
# Continue.
|
||||
else if sourceCode.startsWith('"use 6to5"') or sourceCode.startsWith("'use 6to5'")
|
||||
packageName
|
||||
directory = filePath
|
||||
until packageName
|
||||
directory = path.dirname(directory)
|
||||
manifest = path.join(directory, 'package.json')
|
||||
if fs.existsSync(manifest)
|
||||
json = JSON.parse(fs.readFileSync(manifest))
|
||||
packageName = json.name
|
||||
else if isRoot(directory)
|
||||
break
|
||||
|
||||
# Create a manual deprecation since the stack is too deep to use Grim
|
||||
# which limits the depth to 3
|
||||
Grim ?= require 'grim'
|
||||
Grim.deprecate("Use the 'use babel' pragma instead of 'use 6to5' in #{filePath}", {packageName})
|
||||
stack = [
|
||||
{
|
||||
fileName: __filename
|
||||
functionName: 'loadFile'
|
||||
location: "#{__filename}:161:5"
|
||||
}
|
||||
{
|
||||
fileName: filePath
|
||||
functionName: '<unknown>'
|
||||
location: "#{filePath}:1:1"
|
||||
}
|
||||
]
|
||||
deprecation =
|
||||
message: "Use the 'use babel' pragma instead of 'use 6to5'"
|
||||
stacks: [stack]
|
||||
Grim.addSerializedDeprecation(deprecation)
|
||||
else
|
||||
return module._compile(sourceCode, filePath)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user