mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2025-01-06 23:26:25 +03:00
Add requireWithGlobals() to atom global
This commit is contained in:
parent
dc9c59f0b3
commit
333c5a0db2
@ -273,3 +273,17 @@ class Atom
|
||||
require userInitScriptPath if fsUtils.isFileSync(userInitScriptPath)
|
||||
catch error
|
||||
console.error "Failed to load `#{userInitScriptPath}`", error.stack, error
|
||||
|
||||
requireWithGlobals: (id, globals={}) ->
|
||||
existingGlobals = {}
|
||||
for key, value of globals
|
||||
existingGlobals[key] = window[key]
|
||||
window[key] = value
|
||||
|
||||
require(id)
|
||||
|
||||
for key, value of existingGlobals
|
||||
if value is undefined
|
||||
delete window[key]
|
||||
else
|
||||
window[key] = value
|
||||
|
@ -123,20 +123,8 @@ window.deserialize = (args...) ->
|
||||
atom.deserializers.deserialize(args...)
|
||||
window.getDeserializer = (args...) ->
|
||||
atom.deserializer.getDeserializer(args...)
|
||||
|
||||
window.requireWithGlobals = (id, globals={}) ->
|
||||
existingGlobals = {}
|
||||
for key, value of globals
|
||||
existingGlobals[key] = window[key]
|
||||
window[key] = value
|
||||
|
||||
require(id)
|
||||
|
||||
for key, value of existingGlobals
|
||||
if value is undefined
|
||||
delete window[key]
|
||||
else
|
||||
window[key] = value
|
||||
window.requireWithGlobals = (args...) ->
|
||||
atom.requireWithGlobals(args...)
|
||||
|
||||
window.measure = (description, fn) ->
|
||||
start = new Date().getTime()
|
||||
|
Loading…
Reference in New Issue
Block a user