Use node's Environment feature to add "require" in renderer.
This commit is contained in:
parent
2413eebd7b
commit
886ebdb002
16 changed files with 180 additions and 166 deletions
23
renderer/lib/init.coffee
Normal file
23
renderer/lib/init.coffee
Normal file
|
@ -0,0 +1,23 @@
|
|||
path = require 'path'
|
||||
|
||||
# Expose information of current process.
|
||||
process.__atom_type = 'renderer'
|
||||
process.resourcesPath = path.resolve process.argv[1], '..', '..', '..'
|
||||
|
||||
# We modified the original process.argv to let node.js load the
|
||||
# atom-renderer.js, we need to restore it here.
|
||||
process.argv.splice 1, 1
|
||||
|
||||
# Add renderer/api/lib to require's search paths, which contains javascript part
|
||||
# of Atom's built-in libraries.
|
||||
globalPaths = require('module').globalPaths
|
||||
globalPaths.push path.join process.resourcesPath, 'renderer', 'api', 'lib'
|
||||
|
||||
# And also common/api/lib
|
||||
globalPaths.push path.join process.resourcesPath, 'common', 'api', 'lib'
|
||||
|
||||
# Expose global variables.
|
||||
global.require = require
|
||||
global.module = module
|
||||
global.__filename = __filename
|
||||
global.__dirname = __dirname
|
Loading…
Add table
Add a link
Reference in a new issue