2015-02-04 18:45:17 +00:00
|
|
|
return (process, require, asarSource) ->
|
|
|
|
{createArchive} = process.binding 'atom_common_asar'
|
|
|
|
|
|
|
|
# Make asar.coffee accessible via "require".
|
|
|
|
process.binding('natives').ATOM_SHELL_ASAR = asarSource
|
|
|
|
|
|
|
|
# Monkey-patch the fs module.
|
|
|
|
require('ATOM_SHELL_ASAR').wrapFsWithAsar require('fs')
|
|
|
|
|
|
|
|
# Make graceful-fs work with asar.
|
|
|
|
source = process.binding 'natives'
|
2015-05-20 05:29:05 +00:00
|
|
|
source['original-fs'] = source.fs
|
|
|
|
source['fs'] = """
|
2015-02-04 18:45:17 +00:00
|
|
|
var src = '(function (exports, require, module, __filename, __dirname) { ' +
|
2015-05-20 05:29:05 +00:00
|
|
|
process.binding('natives')['original-fs'] +
|
2015-02-04 18:45:17 +00:00
|
|
|
' });';
|
|
|
|
var vm = require('vm');
|
|
|
|
var fn = vm.runInThisContext(src, { filename: 'fs.js' });
|
|
|
|
fn(exports, require, module);
|
|
|
|
var asar = require('ATOM_SHELL_ASAR');
|
|
|
|
asar.wrapFsWithAsar(exports);
|
|
|
|
"""
|