mirror of
https://github.com/atom/atom.git
synced 2026-01-23 05:48:10 -05:00
Defer requires until the cache is populated
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
Module = require 'module'
|
||||
path = require 'path'
|
||||
fs = require 'fs-plus'
|
||||
semver = require 'semver'
|
||||
|
||||
fs = null # Defer so the cache is used
|
||||
semver = null # Defer so the cache is used
|
||||
|
||||
nativeModules = process.binding('natives')
|
||||
|
||||
@@ -15,6 +16,10 @@ cache =
|
||||
registered: false
|
||||
resourcePath: null
|
||||
|
||||
requireDependencies = ->
|
||||
fs ?= require 'fs-plus'
|
||||
semver ?= require 'semver'
|
||||
|
||||
loadDependencies = (modulePath, rootPath, rootMetadata, moduleCache) ->
|
||||
for childPath in fs.listSync(path.join(modulePath, 'node_modules'))
|
||||
continue if path.basename(childPath) is '.bin'
|
||||
@@ -172,6 +177,8 @@ if cache.debug
|
||||
foundPath
|
||||
|
||||
exports.create = (modulePath) ->
|
||||
requireDependencies()
|
||||
|
||||
modulePath = fs.realpathSync(modulePath)
|
||||
metadataPath = path.join(modulePath, 'package.json')
|
||||
metadata = JSON.parse(fs.readFileSync(metadataPath))
|
||||
@@ -201,6 +208,7 @@ exports.register = ({resourcePath, devMode}={}) ->
|
||||
cache.registered = true
|
||||
cache.resourcePath = resourcePath
|
||||
registerBuiltins(devMode)
|
||||
requireDependencies()
|
||||
|
||||
return
|
||||
|
||||
|
||||
Reference in New Issue
Block a user